PHP Class JBZoo\Utils\Ser

Datei anzeigen Open project: jbzoo/utils Class Usage Examples

Public Methods

Method Description
fix ( string $brokenSerializedData ) : string Unserializes partially-corrupted arrays that occur sometimes. Addresses specifically the unserialize(): Error at offset xxx of yyy bytes error.
is ( mixed $data ) : boolean Check value to find if it was serialized.
maybe ( mixed $data ) : mixed Serialize data, if needed.
maybeUn ( string $data ) : mixed Unserialize value only if it is serialized.

Protected Methods

Method Description
_checkBasic ( string $data, integer $length ) : boolean Check some basic requirements of all serialized strings

Method Details

_checkBasic() protected static method

Check some basic requirements of all serialized strings
protected static _checkBasic ( string $data, integer $length ) : boolean
$data string
$length integer
return boolean

fix() public static method

NOTE: This error can *frequently* occur with mismatched character sets and higher-than-ASCII characters. Contributed by Theodore R. Smith of PHP Experts, Inc.
public static fix ( string $brokenSerializedData ) : string
$brokenSerializedData string
return string

is() public static method

If $data is not an string, then returned value will always be false. Serialized data is always a string.
public static is ( mixed $data ) : boolean
$data mixed Value to check to see if was serialized
return boolean

maybe() public static method

Serialize data, if needed.
public static maybe ( mixed $data ) : mixed
$data mixed Data that might need to be serialized
return mixed

maybeUn() public static method

Unserialize value only if it is serialized.
public static maybeUn ( string $data ) : mixed
$data string A variable that may or may not be serialized
return mixed