| Total Complexity | 3 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class IncludesAllRule implements Rule |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var mixed $collection |
||
| 12 | */ |
||
| 13 | protected $collection; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Create a new rule instance. |
||
| 17 | * |
||
| 18 | * @param mixed $collection Array to validate against. |
||
| 19 | * @return void |
||
| 20 | */ |
||
| 21 | public function __construct($collection) |
||
| 22 | { |
||
| 23 | $this->collection = $collection; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * This check passes if $value has at least one of |
||
| 28 | * every element in $this->collection. |
||
| 29 | * @param mixed $attribute |
||
| 30 | * @param mixed $value |
||
| 31 | * @return boolean |
||
| 32 | */ |
||
| 33 | public function passes($attribute, $value) |
||
| 34 | { |
||
| 35 | // Diff should return an empty array if all elements in |
||
| 36 | // $this->collection are present in $value. |
||
| 37 | return empty(array_diff($this->collection, $value)); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function message() |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |