| Conditions | 16 |
| Paths | 384 |
| Total Lines | 56 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 173 | public function send(Mail $mail): bool |
||
| 174 | { |
||
| 175 | foreach ($this->bcc() as $key => $value) { |
||
| 176 | if (empty($value) || ! is_string($value)) { |
||
| 177 | continue; |
||
| 178 | } |
||
| 179 | |||
| 180 | if (is_string($key)) { |
||
| 181 | $mail->bcc($key, $value); |
||
| 182 | } else { |
||
| 183 | $mail->bcc($value); |
||
| 184 | } |
||
| 185 | } |
||
| 186 | |||
| 187 | foreach ($this->cc() as $key => $value) { |
||
| 188 | if (empty($value) || ! is_string($value)) { |
||
| 189 | continue; |
||
| 190 | } |
||
| 191 | |||
| 192 | if (is_string($key)) { |
||
| 193 | $mail->cc($key, $value); |
||
| 194 | } else { |
||
| 195 | $mail->cc($value); |
||
| 196 | } |
||
| 197 | } |
||
| 198 | |||
| 199 | $content = $this->content(); |
||
| 200 | |||
| 201 | if (! empty($content['view'])) { |
||
| 202 | $mail->view($content['view'], $this->data()); |
||
| 203 | } elseif (! empty($content['html'])) { |
||
| 204 | $mail->html($content['html']); |
||
| 205 | } |
||
| 206 | if (! empty($content['text'])) { |
||
| 207 | $mail->text($content['text']); |
||
| 208 | } |
||
| 209 | |||
| 210 | $mail->from(...$this->from()); |
||
|
|
|||
| 211 | $mail->header($this->headers()); |
||
| 212 | $mail->priority($this->priority()); |
||
| 213 | |||
| 214 | foreach ($this->replyTo() as $key => $value) { |
||
| 215 | if (empty($value) || ! is_string($value)) { |
||
| 216 | continue; |
||
| 217 | } |
||
| 218 | |||
| 219 | if (is_string($key)) { |
||
| 220 | $mail->replyTo($key, $value); |
||
| 221 | } else { |
||
| 222 | $mail->replyTo($value); |
||
| 223 | } |
||
| 224 | } |
||
| 225 | |||
| 226 | $mail->subject($this->subject()); |
||
| 227 | |||
| 228 | return $mail->send(); |
||
| 229 | } |
||
| 231 |