Conditions | 6 |
Paths | 12 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
37 | protected function attachToRequest(ServerRequestInterface $request = null): ServerRequestInterface |
||
38 | { |
||
39 | if (property_exists($this, 'request')) { |
||
40 | $request = $request ?: $this->request; |
||
41 | } |
||
42 | assert($request instanceof ServerRequestInterface); |
||
43 | |||
44 | $key = defined('static::ATTR_KEY') ? constant('static::ATTR_KEY') : static::class; |
||
45 | if ($request->getAttribute($key)) { |
||
46 | throw new \RuntimeException('attribute collision:' . $key); |
||
47 | } |
||
48 | |||
49 | $request = $request->withAttribute($key, $this); |
||
50 | if (property_exists($this, 'request')) { |
||
51 | $this->request = $request; |
||
52 | } |
||
53 | return $request; |
||
54 | } |
||
56 |