Serialize any object into array and format it JSON or XML
Just use the Serializer class with any kind of object, stdClass or array;
$serializer = new \ByJG\Serializer\SerializerObject($data);
$result = $object->build();
$result
is an array. You can use a Formatter to transform it in JSON or XML.
$serializer = new \ByJG\Serializer\SerializerObject($data);
$result = $object->build();
echo (new JsonFormatter())->process($result);
echo (new XmlFormatter())->process($result);
// Create the class
class MyClass extends BinderObject
{}
// Bind any data into the properties of myclass
$myclass->bind($data);
// You can convert to array all properties
$myclass->toArray();
or
// Set all properties from $source that matches with the property in $target
BinderObject::bindObject($source, $target);
// Convert all properties of any object into array
BinderObject::toArrayFrom($source);
composer require "byjg/serialize=1.0.*"
phpunit