| Conditions | 5 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 57 | 4 | public function __invoke($input) |
|
| 58 | { |
||
| 59 | 4 | if (!is_object($input)) { |
|
| 60 | 1 | throw new UnexpectedTypeException($input, 'object'); |
|
| 61 | } |
||
| 62 | |||
| 63 | 3 | if (null === $this->propertyPath && !method_exists($input, '__toString')) { |
|
| 64 | 1 | throw new \RuntimeException; |
|
| 65 | } |
||
| 66 | |||
| 67 | 2 | if (null === $this->propertyPath) { |
|
| 68 | 1 | return (string) $input; |
|
| 69 | } |
||
| 70 | |||
| 71 | 1 | $path = new PropertyPath($this->propertyPath); |
|
| 72 | |||
| 73 | 1 | return $this->propertyAccessor->getValue($input, $path); |
|
| 74 | } |
||
| 75 | } |
||
| 76 |