Created
June 22, 2015 15:06
-
-
Save frankdejonge/354fa45dd9d786875962 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Any implements Specification | |
{ | |
private $specifications = []; | |
public function __construct(array $specifications = []) | |
{ | |
$this->specifications = $specifications; | |
} | |
public function isSatisfiedBy($payload) | |
{ | |
foreach ($this->specifications as $specification) { | |
if ($specification->isSatisfiedBy($payload)) { | |
return true; | |
} | |
} | |
return empty($this->specifications); | |
} | |
} | |
class All implements Specification | |
{ | |
private $specifications = []; | |
public function __construct(array $specifications = []) | |
{ | |
$this->specifications = $specifications; | |
} | |
public function isSatisfiedBy($payload) | |
{ | |
foreach ($this->specifications as $specification) { | |
if (! $specification->isSatisfiedBy($payload)) { | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment