Passed
Push — master ( 8c447f...2d37d5 )
by Todd
02:21
created

IsIterable::validate()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 3
nop 1
crap 4
1
<?php
2
3
namespace Logikos\Util\Validation\Validator;
4
5
6
use Logikos\Util\Validation\Validator;
7
8
class IsIterable implements Validator {
9
  private $description;
10
11 5
  public function __construct($description = null) {
12 5
    if (!is_null($description))
13 1
      $this->description = $description;
14 5
  }
15
16 4
  public function validate($value): bool {
17 4
    if (is_array($value)) return true;
18 3
    if (is_object($value) && $value instanceof \Traversable) return true;
19 1
    return false;
20
  }
21
22 1
  public function getDescription() {
23 1
    return $this->description;
24
  }
25
}