| Conditions | 18 |
| Paths | 65 |
| Total Lines | 42 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 72 | protected function write(array $record) |
||
| 73 | { |
||
| 74 | if (!$this->isNewRelicEnabled()) { |
||
| 75 | throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler'); |
||
| 76 | } |
||
| 77 | |||
| 78 | if ($appName = $this->getAppName($record['context'])) { |
||
| 79 | $this->setNewRelicAppName($appName); |
||
| 80 | } |
||
| 81 | |||
| 82 | if ($transactionName = $this->getTransactionName($record['context'])) { |
||
| 83 | $this->setNewRelicTransactionName($transactionName); |
||
| 84 | unset($record['formatted']['context']['transaction_name']); |
||
| 85 | } |
||
| 86 | |||
| 87 | if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { |
||
| 88 | newrelic_notice_error($record['message'], $record['context']['exception']); |
||
| 89 | unset($record['formatted']['context']['exception']); |
||
| 90 | } else { |
||
| 91 | newrelic_notice_error($record['message']); |
||
| 92 | } |
||
| 93 | |||
| 94 | if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) { |
||
| 95 | foreach ($record['formatted']['context'] as $key => $parameter) { |
||
| 96 | if (is_array($parameter) && $this->explodeArrays) { |
||
| 97 | foreach ($parameter as $paramKey => $paramValue) { |
||
| 98 | $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue); |
||
| 99 | } |
||
| 100 | } else { |
||
| 101 | $this->setNewRelicParameter('context_' . $key, $parameter); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) { |
||
| 107 | foreach ($record['formatted']['extra'] as $key => $parameter) { |
||
| 108 | if (is_array($parameter) && $this->explodeArrays) { |
||
| 109 | foreach ($parameter as $paramKey => $paramValue) { |
||
| 110 | $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue); |
||
| 111 | } |
||
| 112 | } else { |
||
| 113 | $this->setNewRelicParameter('extra_' . $key, $parameter); |
||
| 114 | } |
||
| 203 |