| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | abstract class AbstractBoundRule extends AbstractMinMaxRule |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @param string $parameterName |
||
| 16 | * @param mixed $value |
||
| 17 | * @param bool $itemType |
||
| 18 | * @return string |
||
| 19 | */ |
||
| 20 | final public function testConditions($parameterName, $value, $itemType = false) |
||
| 21 | { |
||
| 22 | if (is_numeric($value)) { |
||
| 23 | $test = '$%1$s %3$s %2$d'; |
||
| 24 | } else { |
||
| 25 | $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\')))'; |
||
| 26 | } |
||
| 27 | return sprintf(($itemType ? '' : '!is_null($%1$s) && ') . $test, $parameterName, $value, static::symbol()); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $parameterName |
||
| 32 | * @param mixed $value |
||
| 33 | * @param bool $itemType |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | final public function exceptionMessageOnTestFailure($parameterName, $value, $itemType = false) |
||
| 39 | } |
||
| 40 | } |
||
| 41 |