| Total Complexity | 8 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 77.78% |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | class IsNumeric implements ConstraintInterface |
||
| 24 | { |
||
| 25 | |||
| 26 | private $isNumeric; |
||
| 27 | |||
| 28 | 28 | public function __construct($value) |
|
| 29 | { |
||
| 30 | 28 | $this->isNumeric = $value; |
|
| 31 | 28 | } |
|
| 32 | |||
| 33 | /** |
||
|
1 ignored issue
–
show
|
|||
| 34 | * @param $value |
||
|
1 ignored issue
–
show
|
|||
| 35 | * @param int|null $citationNumber |
||
|
2 ignored issues
–
show
|
|||
| 36 | * @return bool |
||
|
1 ignored issue
–
show
|
|||
| 37 | */ |
||
| 38 | 12 | public function validate($value, $citationNumber = null) |
|
| 39 | { |
||
| 40 | 12 | if (isset($value->{$this->isNumeric})) { |
|
| 41 | 2 | return $this->parseValue($value->{$this->isNumeric}); |
|
| 42 | } |
||
| 43 | |||
| 44 | 11 | return false; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Tests whether the given variables (Appendix IV - Variables) contain numeric content. Content is considered |
||
| 49 | * numeric if it solely consists of numbers. Numbers may have prefixes and suffixes (“D2”, “2b”, “L2d”), and may be |
||
| 50 | * separated by a comma, hyphen, or ampersand, with or without spaces (“2, 3”, “2-4”, “2 & 4”). For example, “2nd” |
||
| 51 | * tests “true” whereas “second” and “2nd edition” test “false”. |
||
| 52 | * |
||
| 53 | * @param $evalValue |
||
|
1 ignored issue
–
show
|
|||
| 54 | * @return bool |
||
|
1 ignored issue
–
show
|
|||
| 55 | */ |
||
| 56 | 2 | private function parseValue($evalValue) |
|
| 69 | } |
||
| 70 | } |