Total Complexity | 8 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
8 | class IsIterable implements Validator { |
||
9 | private $description; |
||
10 | |||
11 | const DEFAULT_DESCRIPTION = 'Must be iterable'; |
||
12 | |||
13 | 6 | public function __construct($description = null) { |
|
14 | 6 | if (!is_null($description)) |
|
15 | 1 | $this->description = $description; |
|
16 | 6 | } |
|
17 | |||
18 | 4 | public function validate($value): bool { |
|
19 | 4 | if (is_array($value)) return true; |
|
20 | 3 | if (is_object($value) && $value instanceof \Traversable) return true; |
|
21 | 1 | return false; |
|
22 | } |
||
23 | |||
24 | 2 | public function getDescription() { |
|
26 | } |
||
27 | } |