Conditions | 12 |
Paths | 513 |
Total Lines | 90 |
Code Lines | 57 |
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 |
||
122 | public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) |
||
123 | { |
||
124 | $failedRecipients = (array) $failedRecipients; |
||
125 | |||
126 | if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { |
||
127 | $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); |
||
128 | if ($evt->bubbleCancelled()) { |
||
129 | return 0; |
||
130 | } |
||
131 | } |
||
132 | |||
133 | $count = ( |
||
134 | count((array) $message->getTo()) |
||
135 | + count((array) $message->getCc()) |
||
136 | + count((array) $message->getBcc()) |
||
137 | ); |
||
138 | |||
139 | $toHeader = $message->getHeaders()->get('To'); |
||
140 | $subjectHeader = $message->getHeaders()->get('Subject'); |
||
141 | |||
142 | if (0 === $count) { |
||
143 | $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); |
||
144 | } |
||
145 | $to = $toHeader ? $toHeader->getFieldBody() : ''; |
||
146 | $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; |
||
147 | |||
148 | $reversePath = $this->_getReversePath($message); |
||
149 | |||
150 | // Remove headers that would otherwise be duplicated |
||
151 | $message->getHeaders()->remove('To'); |
||
152 | $message->getHeaders()->remove('Subject'); |
||
153 | |||
154 | $messageStr = $message->toString(); |
||
155 | |||
156 | if ($toHeader) { |
||
157 | $message->getHeaders()->set($toHeader); |
||
158 | } |
||
159 | $message->getHeaders()->set($subjectHeader); |
||
160 | |||
161 | // Separate headers from body |
||
162 | if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) { |
||
163 | $headers = substr($messageStr, 0, $endHeaders) . "\r\n"; //Keep last EOL |
||
164 | $body = substr($messageStr, $endHeaders + 4); |
||
165 | } else { |
||
166 | $headers = $messageStr . "\r\n"; |
||
167 | $body = ''; |
||
168 | } |
||
169 | |||
170 | unset($messageStr); |
||
171 | |||
172 | if ("\r\n" != PHP_EOL) { |
||
173 | // Non-windows (not using SMTP) |
||
174 | $headers = str_replace("\r\n", PHP_EOL, $headers); |
||
175 | $subject = str_replace("\r\n", PHP_EOL, $subject); |
||
176 | $body = str_replace("\r\n", PHP_EOL, $body); |
||
177 | $to = str_replace("\r\n", PHP_EOL, $to); |
||
178 | } else { |
||
179 | // Windows, using SMTP |
||
180 | $headers = str_replace("\r\n.", "\r\n..", $headers); |
||
181 | $subject = str_replace("\r\n.", "\r\n..", $subject); |
||
182 | $body = str_replace("\r\n.", "\r\n..", $body); |
||
183 | $to = str_replace("\r\n.", "\r\n..", $to); |
||
184 | } |
||
185 | |||
186 | if ($this->_invoker->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) { |
||
187 | if ($evt) { |
||
188 | $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); |
||
189 | $evt->setFailedRecipients($failedRecipients); |
||
190 | $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); |
||
191 | } |
||
192 | } else { |
||
193 | $failedRecipients = array_merge( |
||
194 | $failedRecipients, |
||
195 | array_keys((array) $message->getTo()), |
||
196 | array_keys((array) $message->getCc()), |
||
197 | array_keys((array) $message->getBcc()) |
||
198 | ); |
||
199 | |||
200 | if ($evt) { |
||
201 | $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); |
||
202 | $evt->setFailedRecipients($failedRecipients); |
||
203 | $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); |
||
204 | } |
||
205 | |||
206 | $message->generateId(); |
||
207 | |||
208 | $count = 0; |
||
209 | } |
||
210 | |||
211 | return $count; |
||
212 | } |
||
315 |
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