-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Rafael Santos edited this page Jun 22, 2016
·
1 revision
Array to object conversion library. Convert a array to a object using simple and common property annotations
class Team
{
/**
* @var string
*/
protected $name;
/**
* @var array|Player[]
*/
protected $players;
//getters and setters
}
class Player
{
/**
* @var string
*/
protected $name;
/**
* @var integer
*/
protected $number;
//getters and setters
}
$teamArray = [
'name' => 'Dream Team',
'players' =>
[
[
'name' => 'Player 1',
'number' => '1',
]
],
];
$person = Array2ObjectBuilder::create()->build()->createObject(Person::class, ['name' => 'David Smith', 'age' => '18']);
echo $person->getName(); //David Smith