Conditions | 5 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
44 | 12 | public function validate($value, $field = null, $allFields = null) |
|
45 | { |
||
46 | 12 | $allowedTypes = (array) $this->getParameter(); |
|
47 | |||
48 | 12 | foreach ($allowedTypes as $type) |
|
49 | { |
||
50 | 11 | $isFunction = 'is_'.$type; |
|
51 | |||
52 | 11 | if (function_exists($isFunction) and $isFunction($value)) |
|
53 | { |
||
54 | 5 | return true; |
|
55 | } |
||
56 | 8 | elseif ($value instanceof $type) |
|
57 | { |
||
58 | 8 | return true; |
|
59 | } |
||
60 | } |
||
61 | |||
62 | 6 | return false; |
|
63 | } |
||
64 | |||
66 |