when = $when; $this->then = $then; if (null === $else) { $else = new AlwaysInvalid(); $else->setTemplate(AlwaysInvalidException::SIMPLE); } $this->else = $else; } public function validate($input) { if ($this->when->validate($input)) { return $this->then->validate($input); } else { return $this->else->validate($input); } } public function assert($input) { if ($this->when->validate($input)) { return $this->then->assert($input); } else { return $this->else->assert($input); } } public function check($input) { if ($this->when->validate($input)) { return $this->then->check($input); } else { return $this->else->check($input); } } }