| Conditions | 1 |
| Paths | 1 |
| Total Lines | 10 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 1 |
| Changes | 2 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 14 | 8 | public function applyRule($parameterName, $value, $itemType = false) |
|
| 15 | { |
||
| 16 | 6 | $this |
|
| 17 | 8 | ->getMethod() |
|
| 18 | 8 | ->addChild('// validation for constraint: totalDigits') |
|
| 19 | 8 | ->addChild(sprintf('if (is_float($%1$s) && strlen(str_replace(array(\' \', \'.\', \',\', \'-\', \'+\'), \'\', $%1$s)) !== %2$d) {', $parameterName, $value)) |
|
| 20 | 8 | ->addChild($this->getMethod()->getIndentedString(sprintf('throw new \InvalidArgumentException(sprintf(\'Invalid value, the value must at most contain %1$d digits, "%%d" given\', strlen(substr($%2$s, strpos($%2$s, \'.\')))), __LINE__);', $value, $parameterName), 1)) |
|
| 21 | 8 | ->addChild('}'); |
|
| 22 | 8 | return $this; |
|
| 23 | } |
||
| 24 | } |
||
| 25 |