| Conditions | 19 |
| Paths | 157 |
| Total Lines | 53 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 56 | public function onKernelResponse(KernelResponseEvent $event): void |
||
| 57 | { |
||
| 58 | if (!$event->isMasterRequest()) { |
||
| 59 | return; |
||
| 60 | } |
||
| 61 | |||
| 62 | if (null === $this->newRelicTwigExtension || false === $this->newRelicTwigExtension->isUsed()) { |
||
| 63 | foreach ($this->newRelic->getCustomMetrics() as $name => $value) { |
||
| 64 | $this->interactor->addCustomMetric((string) $name, (float) $value); |
||
| 65 | } |
||
| 66 | |||
| 67 | foreach ($this->newRelic->getCustomParameters() as $name => $value) { |
||
| 68 | $this->interactor->addCustomParameter((string) $name, $value); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | foreach ($this->newRelic->getCustomEvents() as $name => $events) { |
||
| 73 | foreach ($events as $attributes) { |
||
| 74 | $this->interactor->addCustomEvent((string) $name, $attributes); |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | if ($this->instrument) { |
||
| 79 | if (null === $this->newRelicTwigExtension || false === $this->newRelicTwigExtension->isUsed()) { |
||
| 80 | $this->interactor->disableAutoRUM(); |
||
| 81 | } |
||
| 82 | |||
| 83 | // Some requests might not want to get instrumented |
||
| 84 | if ($event->getRequest()->attributes->get('_instrument', true)) { |
||
| 85 | $response = $event->getResponse(); |
||
| 86 | |||
| 87 | // We can only instrument HTML responses |
||
| 88 | if (!$response instanceof StreamedResponse |
||
| 89 | && 'text/html' === \substr($response->headers->get('Content-Type', ''), 0, 9) |
||
| 90 | ) { |
||
| 91 | $responseContent = $response->getContent(); |
||
| 92 | $response->setContent(''); // free the memory |
||
| 93 | |||
| 94 | if (null === $this->newRelicTwigExtension || false === $this->newRelicTwigExtension->isHeaderCalled()) { |
||
| 95 | $responseContent = \preg_replace('|<head>|i', '$0'.$this->interactor->getBrowserTimingHeader(), $responseContent); |
||
| 96 | } |
||
| 97 | |||
| 98 | if (null === $this->newRelicTwigExtension || false === $this->newRelicTwigExtension->isFooterCalled()) { |
||
| 99 | $responseContent = \preg_replace('|</body>|i', $this->interactor->getBrowserTimingFooter().'$0', $responseContent); |
||
| 100 | } |
||
| 101 | |||
| 102 | $response->setContent($responseContent); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | if ($this->symfonyCache) { |
||
| 108 | $this->interactor->endTransaction(); |
||
| 109 | } |
||
| 118 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths