PHP code example of keven / instantiator

1. Go to this page and download the library: Download keven/instantiator 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/ */

    

keven / instantiator example snippets




use Keven\Instantiator\Instantiator;

class User
{
    public function __construct(string $emailAddress, string $password, string $userName = null)
    {
        // ...
    }
}

$user = (new Instantiator)->instantiate(
            User::class,
            [
                'emailAddress' => '[email protected]',
                'password' => 'CorrectHorseBatteryStaple',
            ]
        );



// ...

$userCreator = (new Instantiator)->partial(
            User::class,
            [
                'emailAddress' => '[email protected]',
            ]
        );

$user = $userCreator(['password' => 'Tr0ub4dor&3']);