PHP code example of guil95 / builder

1. Go to this page and download the library: Download guil95/builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

guil95 / builder example snippets



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;
    }
}


//Sample build person
$person = Person::buildAssoc([
    'age' => 24,
    'name' => 'Guilherme Henrique Rodrigues',
    'occupation' => Occupation::buildAssoc([
        'description' => 'Software Engineer',
    ])
]);