Conditions | 1 |
Paths | 1 |
Total Lines | 10 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 1 |
Changes | 3 | ||
Bugs | 1 | Features | 2 |
1 | <?php |
||
14 | 4 | public function applyRule($parameterName, $value, $itemType = false) |
|
15 | { |
||
16 | 3 | $this |
|
17 | 4 | ->getMethod() |
|
18 | 4 | ->addChild('// validation for constraint: pattern') |
|
19 | 4 | ->addChild(sprintf('if (is_scalar($%1$s) && !preg_match(\'/%2$s/\', $%1$s)) {', $parameterName, $value)) |
|
20 | 4 | ->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(sprintf(\'Invalid value, please provide a scalar value that matches "%s", "%%s" given\', var_export($%s, true)), __LINE__);', str_replace("'", "\'", $value), $parameterName), 1)) |
|
21 | 4 | ->addChild('}'); |
|
22 | 4 | return $this; |
|
23 | } |
||
24 | } |
||
25 |