PHP magic method used in conjunction with `var_export()` to allow objects to be
re-instantiated with their pre-existing properties and values intact. This method can be
called statically on any class that extends `Object` to return an instance of it.
Parameters
- array $data An array of properties and values with which to re-instantiate the object. These properties can be both public and protected.
Returns
object Returns an instance of the requested object with the given properties set.Source
public static function __set_state($data) {
$class = get_called_class();
$object = new $class();
foreach ($data as $property => $value) {
$object->{$property} = $value;
}
return $object;
}