| Conditions | 7 |
| Paths | 48 |
| Total Lines | 80 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 59 | public function send(Email $email) |
||
| 60 | { |
||
| 61 | Log::debug('Beginning mail send', [ |
||
| 62 | 'email' => $email, |
||
| 63 | ]); |
||
| 64 | try { |
||
| 65 | $message = new Swift_Message( |
||
| 66 | $email->getSubject() |
||
| 67 | ); |
||
| 68 | |||
| 69 | // Sender |
||
| 70 | if ($email->getFrom()) { |
||
| 71 | $message->setFrom( |
||
| 72 | $email->getFrom(), |
||
| 73 | $email->getFromName() |
||
| 74 | ); |
||
| 75 | } else { |
||
| 76 | $message->setFrom( |
||
| 77 | $this->config['from'], |
||
| 78 | $this->config['from_name'] |
||
| 79 | ); |
||
| 80 | } |
||
| 81 | |||
| 82 | // Recipients |
||
| 83 | $destinations = [ |
||
| 84 | 'addTo' => $email->getTo(), |
||
| 85 | 'addCc' => $email->getCc(), |
||
| 86 | 'addBcc' => $email->getBcc(), |
||
| 87 | ]; |
||
| 88 | foreach ($destinations as $setter => $addresses) { |
||
| 89 | foreach ($addresses as $address => $name) { |
||
| 90 | $message->$setter($address, $name); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | // Default template contexts |
||
| 95 | // foreach ($this->config['site'] as $key => $value) { |
||
| 96 | // $email->addTemplateContext( |
||
| 97 | // 'site_' . $key, |
||
| 98 | // $value |
||
| 99 | // ); |
||
| 100 | // } |
||
| 101 | |||
| 102 | // Content |
||
| 103 | $context = $email->getTemplateContext(); |
||
| 104 | $html = $this->twig->render( |
||
| 105 | $email->getTemplateHtml(), |
||
| 106 | $context |
||
| 107 | ); |
||
| 108 | |||
| 109 | try { |
||
| 110 | $text = $this->twig->render( |
||
| 111 | $email->getTemplateText(), |
||
| 112 | $context |
||
| 113 | ); |
||
| 114 | } catch (LoaderError $ex) { |
||
| 115 | $text = strip_tags($html); |
||
| 116 | } |
||
| 117 | $text = trim($text); |
||
| 118 | $html = trim($html); |
||
| 119 | $message->setBody($text); |
||
| 120 | $message->addPart($html, 'text/html'); |
||
| 121 | |||
| 122 | $failed = []; |
||
| 123 | $result = $this->swiftMailer->send($message, $failed); |
||
| 124 | Log::debug('Sent email', [ |
||
| 125 | 'recipient_count' => $result, |
||
| 126 | 'message' => $message, |
||
| 127 | 'failed' => $failed, |
||
| 128 | ]); |
||
| 129 | if (0 == $result) { |
||
| 130 | return false; |
||
| 131 | } |
||
| 132 | |||
| 133 | return true; |
||
| 134 | } catch (Exception $ex) { |
||
| 135 | Log::error($ex->getMessage(), [ |
||
| 136 | 'exception' => $ex, |
||
| 137 | ]); |
||
| 138 | return false; |
||
| 139 | } |
||
| 142 |
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