Converts values to primitive php types (string, integer, float, boolean)
Methods summary
public static
integer
|
#
toInteger( float|integer|string $value )
Converts value to integer type
Converts value to integer type
Parameters
- $value
float|integer|string $value
Returns
integer
Throws
|
public static
array
|
#
toIntegerArray( array $items, mixed $allowNullValues = false )
Converts all values in array to integer types. Resulting array will be
reindexed with numeric indices.
Converts all values in array to integer types. Resulting array will be
reindexed with numeric indices.
Parameters
- $items
array $items
- $allowNullValues
Returns
array
Throws
|
public static
string
|
#
toString( mixed $value )
Converts value to string
Parameters
Returns
string Resulting string
Throws
|
public static
string
|
#
toFixedString( mixed $value, integer $length )
Converts value to string and checks it doesn't exceed maximum length
Converts value to string and checks it doesn't exceed maximum length
Parameters
- $value
mixed $value Value
- $length
integer $length Maximum allowed string length
Returns
string Resulting string
Throws
|
public static
array
|
#
toStringArray( array $items, mixed $allowNullValues = false )
Converts all values in array to string types. Resulting array will be
reindexed with numeric indices.
Converts all values in array to string types. Resulting array will be
reindexed with numeric indices.
Parameters
- $items
array $items Array of values convertible to strings
- $allowNullValues
Returns
array Array of strings with reindexed keys
Throws
|
public static
array
|
#
toFixedStringArray( array $items, type $length, mixed $allowNullValues = false )
Converts all values in array to string types and checks that each string
length doesn't exceed maximum length. Resulting array will be reindexed with
numeric indices.
Converts all values in array to string types and checks that each string
length doesn't exceed maximum length. Resulting array will be reindexed with
numeric indices.
Parameters
- $items
array $items Array of values convertible to strings
- $length
type $length Maximum allowed string length
- $allowNullValues
Returns
array Array of strings with reindexed keys
Throws
|
public static
boolean
|
#
toBoolean( boolean|string|integer $value )
Converts value to boolean; valid string values are: 'true','1',
'on','false','0','off' (all case-insensitive); valid integer values are 0 and
1
Converts value to boolean; valid string values are: 'true','1',
'on','false','0','off' (all case-insensitive); valid integer values are 0 and
1
Parameters
- $value
boolean|string|integer Source value
Returns
boolean Converted value
Throws
|
public static
array
|
#
toBooleanArray( array $items, mixed $allowNullValues = false )
Converts all values in array to bool types. Resulting array will be reindexed
with numeric indices. For list of valid values, see: NGS\Converter\PrimitiveConverter::toBoolean()
Parameters
- $items
array $items Array of values convertible to booleans.
- $allowNullValues
Returns
array Array of booleans with reindexed keys
Throws
|
public static
float
|
#
toFloat( boolean|string|integer $value )
Converts value to float.
Parameters
- $value
boolean|string|integer Source value
Returns
float Converted value
Throws
|
public static
array
|
#
toFloatArray( array $items, mixed $allowNullValues = false )
Converts all values in array to float types. Resulting array will be
reindexed with numeric indices.
Converts all values in array to float types. Resulting array will be
reindexed with numeric indices.
Parameters
- $items
array $items
- $allowNullValues
Returns
array
Throws
|
public static
array
|
#
toMap( array $items )
Converts all values in array to string type. As toStringArray, but preserves
original array keys.
Converts all values in array to string type. As toStringArray, but preserves
original array keys.
Parameters
- $items
array $items Array of values convertible to strings
Returns
array Array of strings with preserved original keys
Throws
|
public static
array
|
#
toMapArray( array $items )
Converts all values in array to string map (string array), runs toMap() on
each element.
Converts all values in array to string map (string array), runs toMap() on
each element.
Parameters
- $items
array $items Array of string maps
Returns
array Array of string arrays with preserved original keys
Throws
|