| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class EnumerationRule extends AbstractRule |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Struct |
||
| 12 | */ |
||
| 13 | protected $model; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @return string |
||
| 17 | */ |
||
| 18 | 114 | public function name() |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param string $parameterName |
||
| 25 | * @param mixed $value |
||
| 26 | * @param bool $itemType |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | 114 | public function testConditions($parameterName, $value, $itemType = false) |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param string $parameterName |
||
| 40 | * @param mixed $value |
||
| 41 | * @param bool $itemType |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | 114 | public function exceptionMessageOnTestFailure($parameterName, $value, $itemType = false) |
|
| 45 | { |
||
| 46 | 114 | $exceptionMessage = ''; |
|
| 47 | 114 | if ($this->getRestrictionModel()) { |
|
| 48 | 114 | $exceptionMessage = sprintf('sprintf(\'Invalid value(s) %%s, please use one of: %%s from enumeration class %2$s\', is_array($%1$s) ? implode(\', \', $%1$s) : var_export($%1$s, true), implode(\', \', %2$s::%3$s()))', $parameterName, $this->getRestrictionModel()->getPackagedName(true), StructEnum::METHOD_GET_VALID_VALUES); |
|
| 49 | 57 | } |
|
| 50 | 114 | return $exceptionMessage; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return Struct|null |
||
| 55 | */ |
||
| 56 | 114 | protected function getRestrictionModel() |
|
| 62 | } |
||
| 63 | } |
||
| 64 |