PHP Trait Webiny\Component\StdLib\StdLibTrait

Inheritance: use trait StdObjectTrait, use trait ValidatorTrait
Show file Open project: Webiny/Framework

Protected Methods

Method Description
jsonDecode ( string $json, boolean $assoc = false, integer $depth = 512, integer $options ) : mixed Decode JSON string
jsonEncode ( mixed $value, integer $options ) : string | boolean
serialize ( array $array ) : string Serializes the given array.
unserialize ( string $string ) : array | mixed Unserializes the given string and returns the array.

Method Details

jsonDecode() protected static method

Decode JSON string
protected static jsonDecode ( string $json, boolean $assoc = false, integer $depth = 512, integer $options ) : mixed
$json string The json string being decoded. This function only works with UTF-8 encoded data.
$assoc boolean When TRUE, returned objects will be converted into associative arrays.
$depth integer User specified recursion depth.
$options integer Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats)
return mixed The value encoded in json in appropriate PHP type. NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.

jsonEncode() protected static method

protected static jsonEncode ( mixed $value, integer $options ) : string | boolean
$value mixed The value being encoded. Can be any type except a resource. This function only works with UTF-8 encoded data.
$options integer
return string | boolean A JSON encoded string on success or FALSE on failure.

serialize() protected static method

Serializes the given array.
protected static serialize ( array $array ) : string
$array array Array to serialize.
return string

unserialize() protected static method

Unserializes the given string and returns the array.
protected static unserialize ( string $string ) : array | mixed
$string string String to serialize.
return array | mixed