Skip to content

Instantly share code, notes, and snippets.

@gnugat
Created September 27, 2015 15:20
Show Gist options
  • Save gnugat/9b6f85f0637dd5e949de to your computer and use it in GitHub Desktop.
Save gnugat/9b6f85f0637dd5e949de to your computer and use it in GitHub Desktop.
An example of a Command (from CommandBus), with default values
<?php
use Assert\Assertion;
class RegisterNewMember
{
public $email;
public $subscribeToNewsletter = true;
public function __construct($email, $subscribeToNewsletter = null)
{
Assertion::email(email);
$this->email = (string) $email;
if (false === $subscribeToNewsletter) {
$this->subscribeToNewsletter = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment