Completed
Push — feat_email_envelope ( e5445d )
by Stefano
02:37
created

Native   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 77.78 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 5
Bugs 2 Features 0
Metric Value
wmc 3
c 5
b 2
f 0
lcom 0
cbo 2
dl 14
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 14 14 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Email\Native
5
 *
6
 * Email\Native PHP mail() driver.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @copyright Caffeina srl - 2016 - http://caffeina.com
11
 */
12
13
namespace Email;
14
15
class Native implements Driver {
16
17 View Code Duplication
  public function send(Envelope $envelope){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    // PHP requires direct handling of To and Subject Headers.
19
    $success     = true;
20
    $recipients  = $envelope->to();
21
    $subject     = $envelope->subject();
22
    $envelope->to(false);
23
    $envelope->subject(false);
24
    foreach ($recipients as $to) {
25
      $current_success = mail($to,$subject,$envelope->body(),$envelope->head());
26
      \Event::trigger('core.email.send',$to,$envelope,'native');
27
      $success = $success && $current_success;
28
    }
29
    return $success;
30
  }
31
32
}
33
34