Completed
Push — master ( efe7e0...af4195 )
by
unknown
03:07
created
classes/Email/Proxy.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
 
17 17
   protected $listener = 'core.email.proxy.send';
18 18
 
19
-  public function onInit($options){
19
+  public function onInit($options) {
20 20
     if (!empty($options['hook'])) $this->listener = $options['hook'];
21 21
   }
22 22
 
23
-  public function onSend(Envelope $envelope){
23
+  public function onSend(Envelope $envelope) {
24 24
     \Event::trigger($this->listener, $envelope);
25 25
     return true;
26 26
   }
Please login to merge, or discard this patch.
classes/Email/Native.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
14 14
 
15 15
 class Native implements Driver {
16 16
   
17
-  public function onInit($options){}
17
+  public function onInit($options) {}
18 18
 
19
-  public function onSend(Envelope $envelope){
19
+  public function onSend(Envelope $envelope) {
20 20
     $results = [];
21 21
     foreach ($envelope->to() as $to) {
22
-      $results[$to] = mail($to,$envelope->subject(),$envelope->body(),$envelope->head());
22
+      $results[$to] = mail($to, $envelope->subject(), $envelope->body(), $envelope->head());
23 23
     }
24 24
     return $results;
25 25
   }
Please login to merge, or discard this patch.
classes/Email/Smtp.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
     $password;
26 26
 
27 27
   public function onInit($options) {
28
-    $options        = (object)$options;
29
-    $this->host     = isset($options->host)     ? $options->host     : 'localhost';
28
+    $options        = (object) $options;
29
+    $this->host     = isset($options->host) ? $options->host : 'localhost';
30 30
     $this->username = isset($options->username) ? $options->username : false;
31
-    $this->secure   = isset($options->secure)   ? $options->secure   : ($this->username ? true : false);
32
-    $this->port     = isset($options->port)     ? $options->port     : ($this->secure ? 465 : 25);
31
+    $this->secure   = isset($options->secure) ? $options->secure : ($this->username ? true : false);
32
+    $this->port     = isset($options->port) ? $options->port : ($this->secure ? 465 : 25);
33 33
     $this->password = isset($options->password) ? $options->password : false;
34 34
   }
35 35
 
36
-  protected function connect(){
36
+  protected function connect() {
37 37
     if ($this->socket) $this->close();
38
-    $url = ($this->secure ? 'tls' : 'tcp') ."://{$this->host}";
39
-    $this->socket = fsockopen( $url, $this->port, $errno, $errstr, 30 );
40
-    if ( ! $this->socket ) throw new \Exception("Unable to connect to $url on port {$this->port}.");
38
+    $url = ($this->secure ? 'tls' : 'tcp')."://{$this->host}";
39
+    $this->socket = fsockopen($url, $this->port, $errno, $errstr, 30);
40
+    if (!$this->socket) throw new \Exception("Unable to connect to $url on port {$this->port}.");
41 41
     $this->lastMessage = '';
42 42
     $this->lastCode = 0;
43 43
   }
44 44
 
45
-  public function close(){
45
+  public function close() {
46 46
     $this->socket && @fclose($this->socket);
47 47
   }
48 48
 
49
-  protected function write($data, $nl = 1){
50
-    $payload = $data . str_repeat("\r\n",$nl);
49
+  protected function write($data, $nl = 1) {
50
+    $payload = $data.str_repeat("\r\n", $nl);
51 51
     fwrite($this->socket, $payload);
52 52
   }
53 53
 
54
-  protected function expectCode($code){
54
+  protected function expectCode($code) {
55 55
 
56 56
     $this->lastMessage = '';
57
-    while (substr($this->lastMessage, 3, 1) != ' '){
57
+    while (substr($this->lastMessage, 3, 1) != ' ') {
58 58
       $this->lastMessage = fgets($this->socket, 256);
59 59
     }
60 60
 
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
     return $code == $this->lastCode;
63 63
   }
64 64
 
65
-  protected function SMTPmail($from,$to,$body){
65
+  protected function SMTPmail($from, $to, $body) {
66 66
     $this->connect();
67 67
     $this->expectCode(220);
68 68
 
69 69
     $this->write("EHLO {$this->host}");
70 70
     $this->expectCode(250);
71 71
 
72
-    if ($this->username){
72
+    if ($this->username) {
73 73
       $this->write("AUTH LOGIN");
74 74
       $this->expectCode(334);
75 75
       $this->write(base64_encode($this->username));
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     return $success;
99 99
   }
100 100
 
101
-  public function onSend(Envelope $envelope){
101
+  public function onSend(Envelope $envelope) {
102 102
     $results = [];
103 103
     foreach ($envelope->to() as $to) {
104 104
       $results[$to] = $this->SMTPmail($envelope->from(), $to, $envelope->build());
Please login to merge, or discard this patch.
classes/Email.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
                    $options,
18 18
                    $driver_name;
19 19
 
20
-  public static function using($driver, $options = null){
20
+  public static function using($driver, $options = null) {
21 21
     $class = 'Email\\'.ucfirst(strtolower($driver));
22
-    if ( ! class_exists($class) ) throw new Exception("[core.email] : $driver driver not found.");
22
+    if (!class_exists($class)) throw new Exception("[core.email] : $driver driver not found.");
23 23
     static::$driver_name = $driver;
24 24
     static::$options     = $options;
25 25
     static::$driver      = new $class;
26 26
     static::$driver->onInit($options);
27 27
   }
28 28
 
29
-  public static function create($mail=[]){
30
-    if (is_a($mail, 'Email\\Envelope')){
29
+  public static function create($mail = []) {
30
+    if (is_a($mail, 'Email\\Envelope')) {
31 31
       return $mail;
32 32
     } else {
33 33
       return new Email\Envelope(array_merge([
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
     }
44 44
   }
45 45
 
46
-  public static function send($mail){
46
+  public static function send($mail) {
47 47
     $envelope = static::create($mail);
48 48
     $results = static::$driver->onSend($envelope);
49 49
     Event::trigger('core.email.send', $envelope->to(), $envelope, static::$driver, $results);
50
-    return array_reduce( $results, function($carry, $item) {
50
+    return array_reduce($results, function($carry, $item) {
51 51
       return $carry && $item;
52
-    }, true );
52
+    }, true);
53 53
   }
54 54
 
55 55
 }
Please login to merge, or discard this patch.