| Conditions | 5 |
| Paths | 8 |
| Total Lines | 18 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 6 | protected function getExceptionMessage(): string |
|
| 39 | { |
||
| 40 | 6 | $name = $this->property->getName(); |
|
| 41 | 6 | $declaredNames = $this->property->getTypes()->declaredNames; |
|
| 42 | 6 | $typeNames = implode("', '", $declaredNames); |
|
| 43 | 6 | $types = count($declaredNames) == 1 ? "of type '{$typeNames}'" : "one of these types: '{$typeNames}'"; |
|
| 44 | 6 | $value = $this->property->getRawValue(); |
|
| 45 | 6 | $actualType = gettype($value); |
|
| 46 | |||
| 47 | 6 | if ($value === null) { |
|
| 48 | 3 | $value = 'null'; |
|
| 49 | 3 | } elseif (is_array($value)) { |
|
| 50 | 1 | $value = 'array'; |
|
| 51 | 2 | } elseif (is_object($value)) { |
|
| 52 | 1 | $value = get_class($value); |
|
| 53 | } |
||
| 54 | |||
| 55 | 6 | return "Invalid type: expected '{$name}' to be {$types}. Got `{$value}` ({$actualType}) instead"; |
|
| 56 | } |
||
| 58 |