Total Complexity | 5 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | abstract class AbstractBoundRule extends AbstractMinMaxRule |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @param string $parameterName |
||
15 | * @param mixed $value |
||
16 | * @param bool $itemType |
||
17 | * @return string |
||
18 | */ |
||
19 | 132 | final public function testConditions($parameterName, $value, $itemType = false) |
|
20 | { |
||
21 | 132 | if (is_numeric($value)) { |
|
22 | 60 | $test = '$%1$s %3$s %2$s'; |
|
23 | 30 | } else { |
|
24 | 72 | $test = '($time = (string) time()) && \DateTime::createFromFormat(\'U\', $time)->add(new \DateInterval(preg_replace(\'/(.*)(\.[0-9]*S)/\', \'$1S\', $%1$s))) %3$s \DateTime::createFromFormat(\'U\', $time)->add(new \DateInterval(preg_replace(\'/(.*)(\.[0-9]*S)/\', \'$1S\', \'%2$s\')))'; |
|
25 | } |
||
26 | 132 | return sprintf(($itemType ? '' : '!is_null($%1$s) && ') . $test, $parameterName, $value, $this->symbol()); |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $parameterName |
||
31 | * @param mixed $value |
||
32 | * @param bool $itemType |
||
33 | * @return string |
||
34 | */ |
||
35 | 132 | final public function exceptionMessageOnTestFailure($parameterName, $value, $itemType = false) |
|
38 | } |
||
39 | } |
||
40 |