| Conditions | 4 |
| Paths | 6 |
| Total Lines | 11 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public static function fromRequest(ServerRequestInterface $request) |
||
| 21 | { |
||
| 22 | $key = defined('static::ATTR_KEY') ? constant('static::ATTR_KEY') : static::class; |
||
| 23 | if (!$instance = $request->getAttribute($key)) { |
||
| 24 | throw new \RuntimeException('attribute empty:' . $key); |
||
| 25 | } |
||
| 26 | if (!$instance instanceof static) { |
||
| 27 | throw new \RuntimeException('instance error:' . $key); |
||
| 28 | } |
||
| 29 | |||
| 30 | return $instance; |
||
| 31 | } |
||
| 56 |