Completed
Push — master ( 653203...665d50 )
by
unknown
03:07
created
classes/Email/Smtp.php 2 patches
Spacing   +18 added lines, -18 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,18 +62,18 @@  discard block
 block discarded – undo
62 62
     return $code == $this->lastCode;
63 63
   }
64 64
 
65
-  protected function cleanAddr($email){
66
-    return preg_replace('((.*?)<([\w.@-]+)>(.*?))','$2',$email);
65
+  protected function cleanAddr($email) {
66
+    return preg_replace('((.*?)<([\w.@-]+)>(.*?))', '$2', $email);
67 67
   }
68 68
 
69
-  protected function SMTPmail($from,$to,$body){
69
+  protected function SMTPmail($from, $to, $body) {
70 70
     $this->connect();
71 71
     $this->expectCode(220);
72 72
 
73 73
     $this->write("EHLO {$this->host}");
74 74
     $this->expectCode(250);
75 75
 
76
-    if ($this->username){
76
+    if ($this->username) {
77 77
       $this->write("AUTH LOGIN");
78 78
       $this->expectCode(334);
79 79
       $this->write(base64_encode($this->username));
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     return $success;
107 107
   }
108 108
 
109
-  public function onSend(Envelope $envelope){
109
+  public function onSend(Envelope $envelope) {
110 110
     $results = [];
111 111
     foreach ($envelope->to() as $to) {
112 112
       $results[$to] = $this->SMTPmail($envelope->from(), $to, $envelope->build());
Please login to merge, or discard this patch.
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,28 +33,32 @@  discard block
 block discarded – undo
33 33
     $this->password = isset($options->password) ? $options->password : false;
34 34
   }
35 35
 
36
-  protected function connect(){
37
-    if ($this->socket) $this->close();
36
+  protected function connect() {
37
+    if ($this->socket) {
38
+      $this->close();
39
+    }
38 40
     $url = ($this->secure ? 'tls' : 'tcp') ."://{$this->host}";
39 41
     $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}.");
42
+    if ( ! $this->socket ) {
43
+      throw new \Exception("Unable to connect to $url on port {$this->port}.");
44
+    }
41 45
     $this->lastMessage = '';
42 46
     $this->lastCode = 0;
43 47
   }
44 48
 
45
-  public function close(){
49
+  public function close() {
46 50
     $this->socket && @fclose($this->socket);
47 51
   }
48 52
 
49
-  protected function write($data, $nl = 1){
53
+  protected function write($data, $nl = 1) {
50 54
     $payload = $data . str_repeat("\r\n",$nl);
51 55
     fwrite($this->socket, $payload);
52 56
   }
53 57
 
54
-  protected function expectCode($code){
58
+  protected function expectCode($code) {
55 59
 
56 60
     $this->lastMessage = '';
57
-    while (substr($this->lastMessage, 3, 1) != ' '){
61
+    while (substr($this->lastMessage, 3, 1) != ' ') {
58 62
       $this->lastMessage = fgets($this->socket, 256);
59 63
     }
60 64
 
@@ -62,18 +66,18 @@  discard block
 block discarded – undo
62 66
     return $code == $this->lastCode;
63 67
   }
64 68
 
65
-  protected function cleanAddr($email){
69
+  protected function cleanAddr($email) {
66 70
     return preg_replace('((.*?)<([\w.@-]+)>(.*?))','$2',$email);
67 71
   }
68 72
 
69
-  protected function SMTPmail($from,$to,$body){
73
+  protected function SMTPmail($from,$to,$body) {
70 74
     $this->connect();
71 75
     $this->expectCode(220);
72 76
 
73 77
     $this->write("EHLO {$this->host}");
74 78
     $this->expectCode(250);
75 79
 
76
-    if ($this->username){
80
+    if ($this->username) {
77 81
       $this->write("AUTH LOGIN");
78 82
       $this->expectCode(334);
79 83
       $this->write(base64_encode($this->username));
@@ -106,7 +110,7 @@  discard block
 block discarded – undo
106 110
     return $success;
107 111
   }
108 112
 
109
-  public function onSend(Envelope $envelope){
113
+  public function onSend(Envelope $envelope) {
110 114
     $results = [];
111 115
     foreach ($envelope->to() as $to) {
112 116
       $results[$to] = $this->SMTPmail($envelope->from(), $to, $envelope->build());
Please login to merge, or discard this patch.
classes/Email/Native.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 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){
20
-    $results 		= [];
21
-    $recipients 	= $envelope->to();
19
+  public function onSend(Envelope $envelope) {
20
+    $results = [];
21
+    $recipients = $envelope->to();
22 22
     $envelope->to(false);
23 23
     foreach ($recipients as $to) {
24
-      $results[$to] = mail($to,$envelope->subject(),$envelope->body(),$envelope->head());
24
+      $results[$to] = mail($to, $envelope->subject(), $envelope->body(), $envelope->head());
25 25
     }
26 26
     return $results;
27 27
   }
Please login to merge, or discard this patch.