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

Native::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 11

Duplication

Lines 14
Ratio 100 %

Importance

Changes 5
Bugs 2 Features 0
Metric Value
c 5
b 2
f 0
dl 14
loc 14
rs 9.4285
cc 3
eloc 11
nc 3
nop 1
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