guil95 / builder
Builder of objects
2.11.0
2019-10-31 18:56 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^8
README
Trait that assists in the hydration of entities or classes that have the methods 'setters'
Install
composer require guil95/hidrate
Sample to use
<?php class Occupation { use Builder; /** * @var string */ private $description; public function __construct(string $description) { $this->description = $description; } } class Person { use Builder; /** * @var integer */ private $age; /** * @var string */ private $name; /** * @var Occupation */ private $occupation; public function __construct(string $name, int $age, Occupation $occupation) { $this->age = $age; $this->name = $name; $this->occupation = $occupation; } }
<?php //Sample build person $person = Person::buildAssoc([ 'age' => 24, 'name' => 'Guilherme Henrique Rodrigues', 'occupation' => Occupation::buildAssoc([ 'description' => 'Software Engineer', ]) ]);
Tests
composer tests
Tests and coverage
make test-report