Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | 16 | public function onKernelResponse(FilterResponseEvent $event) |
|
29 | { |
||
30 | 16 | if (!$this->shouldInject($event)) { |
|
31 | 13 | return; |
|
32 | } |
||
33 | |||
34 | 3 | $response = $event->getResponse(); |
|
35 | 3 | $content = $response->getContent(); |
|
36 | |||
37 | 3 | $pos = strripos($content, '</body>'); |
|
38 | 3 | if (false === $pos) { |
|
39 | 1 | return; |
|
40 | } |
||
41 | |||
42 | 2 | $script = '<script src="'.$this->url.'"></script>'; |
|
43 | 2 | $response->setContent(substr($content, 0, $pos).$script.substr($content, $pos)); |
|
44 | 2 | } |
|
45 | |||
74 |