laracasts / Commander

Easily leverage commands and domain events in your Laravel projects.
https://laracasts.com/series/commands-and-domain-events
MIT License
279 stars 68 forks source link

Type hinting in Command's constructor (value object mapping) #32

Open salebab opened 10 years ago

salebab commented 10 years ago

It would be useful to use a value objects in command, so if you type hint property, mapper will instantiate and pass object.

class RegisterCommand {

    /**
     * @var EmailAddress
     */
    private $email;

    private $password;

    public function __construct(EmailAddress $email, $password)
    {
        $this->email = $email;
        $this->password = $password;
    }
}