Completed
Push — master ( 1f9686...114e61 )
by Stefano
03:01
created
classes/Email/Ses.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     $options  = (object)$options;
19 19
     $region   = isset($options->region) ? $options->region : 'eu-west-1';
20 20
     if (empty($options->username) || empty($options->password))
21
-       throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1);
21
+        throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1);
22 22
 
23 23
     Smtp::onInit([
24 24
       'host'     => "email-smtp.{$region}.amazonaws.com",
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
   public function onSend(Envelope $envelope){
34 34
     if (!$envelope->from())
35
-       throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1);
35
+        throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1);
36 36
     return Smtp::onSend($envelope);
37 37
   }
38 38
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 class Ses extends Smtp {
16 16
 
17 17
   public function onInit($options) {
18
-    $options  = (object)$options;
18
+    $options  = (object) $options;
19 19
     $region   = isset($options->region) ? $options->region : 'eu-west-1';
20 20
     if (empty($options->username) || empty($options->password))
21 21
        throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
   }
32 32
 
33
-  public function onSend(Envelope $envelope){
33
+  public function onSend(Envelope $envelope) {
34 34
     if (!$envelope->from())
35 35
        throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1);
36 36
     return Smtp::onSend($envelope);
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
   public function onInit($options) {
18 18
     $options  = (object)$options;
19 19
     $region   = isset($options->region) ? $options->region : 'eu-west-1';
20
-    if (empty($options->username) || empty($options->password))
21
-       throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1);
20
+    if (empty($options->username) || empty($options->password)) {
21
+           throw new \Exception("[core.email.ses] You must provide an Amazon SES SMTP username and password", 1);
22
+    }
22 23
 
23 24
     Smtp::onInit([
24 25
       'host'     => "email-smtp.{$region}.amazonaws.com",
@@ -30,9 +31,10 @@  discard block
 block discarded – undo
30 31
 
31 32
   }
32 33
 
33
-  public function onSend(Envelope $envelope){
34
-    if (!$envelope->from())
35
-       throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1);
34
+  public function onSend(Envelope $envelope) {
35
+    if (!$envelope->from()) {
36
+           throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1);
37
+    }
36 38
     return Smtp::onSend($envelope);
37 39
   }
38 40
 
Please login to merge, or discard this patch.
classes/Email/Native.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
   
17 17
   public function onInit($options){}
18 18
 
19
-  public function onSend(Envelope $envelope){
19
+  public function onSend(Envelope $envelope) {
20 20
     // PHP requires direct handling of To and Subject Headers.
21 21
     $success     = true;
22 22
     $recipients  = $envelope->to();
Please login to merge, or discard this 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.
classes/Email/Smtp.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
     $this->connect();
67 67
     $this->expectCode(220);
68 68
 
69
-    $this->write("EHLO {$this->host}");
69
+    $this->write("ehlo {$this->host}");
70 70
     $this->expectCode(250);
71 71
 
72 72
     if ($this->username){
Please login to merge, or discard this patch.
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/Redirect.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 class Redirect {
14 14
     use Module;
15 15
 
16
-    public static function to($url){
17
-        if ($link = Filter::with('core.redirect',$url)) {
16
+    public static function to($url) {
17
+        if ($link = Filter::with('core.redirect', $url)) {
18 18
           Response::clean();
19 19
           Response::header('Location', $link);
20 20
           Response::send();
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
         }
23 23
     }
24 24
 
25
-    public static function back(){
26
-        if ($link = Filter::with('core.redirect', (empty($_SERVER['HTTP_REFERER']) ? Request::get('redirect_uri',false) : $_SERVER['HTTP_REFERER']) )){
25
+    public static function back() {
26
+        if ($link = Filter::with('core.redirect', (empty($_SERVER['HTTP_REFERER']) ? Request::get('redirect_uri', false) : $_SERVER['HTTP_REFERER']))) {
27 27
           Response::clean();
28 28
           Response::header('Location', $link);
29 29
           Response::send();
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
         }
32 32
     }
33 33
 
34
-    public static function viaJavaScript($url, $parent=false){
35
-      if ($link = Filter::with('core.redirect', $url)){
34
+    public static function viaJavaScript($url, $parent = false) {
35
+      if ($link = Filter::with('core.redirect', $url)) {
36 36
         Response::type('text/html');
37
-        Response::add('<script>'.($parent?'parent.':'').'location.href="',addslashes($link),'"</script>');
37
+        Response::add('<script>'.($parent ? 'parent.' : '').'location.href="', addslashes($link), '"</script>');
38 38
         Response::send();
39 39
         exit;
40 40
       }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 class Redirect {
14 14
     use Module;
15 15
 
16
-    public static function to($url){
16
+    public static function to($url) {
17 17
         if ($link = Filter::with('core.redirect',$url)) {
18 18
           Response::clean();
19 19
           Response::header('Location', $link);
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
         }
23 23
     }
24 24
 
25
-    public static function back(){
26
-        if ($link = Filter::with('core.redirect', (empty($_SERVER['HTTP_REFERER']) ? Request::get('redirect_uri',false) : $_SERVER['HTTP_REFERER']) )){
25
+    public static function back() {
26
+        if ($link = Filter::with('core.redirect', (empty($_SERVER['HTTP_REFERER']) ? Request::get('redirect_uri',false) : $_SERVER['HTTP_REFERER']) )) {
27 27
           Response::clean();
28 28
           Response::header('Location', $link);
29 29
           Response::send();
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
         }
32 32
     }
33 33
 
34
-    public static function viaJavaScript($url, $parent=false){
35
-      if ($link = Filter::with('core.redirect', $url)){
34
+    public static function viaJavaScript($url, $parent=false) {
35
+      if ($link = Filter::with('core.redirect', $url)) {
36 36
         Response::type('text/html');
37 37
         Response::add('<script>'.($parent?'parent.':'').'location.href="',addslashes($link),'"</script>');
38 38
         Response::send();
Please login to merge, or discard this patch.
classes/FileSystem/Adapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,6 +20,6 @@
 block discarded – undo
20 20
   public function append($path, $data);
21 21
   public function delete($path);
22 22
   public function move($old_path, $new_path);
23
-  public function search($pattern, $recursive=true);
23
+  public function search($pattern, $recursive = true);
24 24
 
25 25
 }
Please login to merge, or discard this patch.
classes/FileSystem/Memory.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,40 +15,40 @@
 block discarded – undo
15 15
 class Memory implements Adapter {
16 16
   protected $storage = [];
17 17
 
18
-  public function exists($path){
18
+  public function exists($path) {
19 19
     return isset($this->storage[$path]);
20 20
   }
21 21
 
22
-  public function read($path){
22
+  public function read($path) {
23 23
     return $this->exists($path) ? $this->storage[$path] : false;
24 24
   }
25 25
 
26
-  public function write($path, $data){
26
+  public function write($path, $data) {
27 27
     $this->storage[$path] = $data;
28 28
   }
29 29
 
30
-  public function append($path, $data){
30
+  public function append($path, $data) {
31 31
     @$this->storage[$path] .= $data;
32 32
   }
33 33
 
34
-  public function move($old, $new){
35
-    if($this->exists($old)){
34
+  public function move($old, $new) {
35
+    if ($this->exists($old)) {
36 36
       $this->storage[$new] = $this->storage[$old];
37 37
       unset($this->storage[$old]);
38 38
       return true;
39 39
     } else return false;
40 40
   }
41 41
 
42
-  public function delete($path){
42
+  public function delete($path) {
43 43
     unset($this->storage[$path]);
44 44
     return true;
45 45
   }
46 46
 
47
-  public function search($pattern, $recursive=true){
47
+  public function search($pattern, $recursive = true) {
48 48
     $results = [];
49
-    $rx_pattern = '('.strtr($pattern,['.'=>'\.','*'=>'.*','?'=>'.']).')Ai';
49
+    $rx_pattern = '('.strtr($pattern, ['.'=>'\.', '*'=>'.*', '?'=>'.']).')Ai';
50 50
     foreach (array_keys($this->storage) as $path) {
51
-      if (preg_match($rx_pattern,$path)) $results[] = $path;
51
+      if (preg_match($rx_pattern, $path)) $results[] = $path;
52 52
     }
53 53
     return $results;
54 54
   }
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,40 +15,44 @@
 block discarded – undo
15 15
 class Memory implements Adapter {
16 16
   protected $storage = [];
17 17
 
18
-  public function exists($path){
18
+  public function exists($path) {
19 19
     return isset($this->storage[$path]);
20 20
   }
21 21
 
22
-  public function read($path){
22
+  public function read($path) {
23 23
     return $this->exists($path) ? $this->storage[$path] : false;
24 24
   }
25 25
 
26
-  public function write($path, $data){
26
+  public function write($path, $data) {
27 27
     $this->storage[$path] = $data;
28 28
   }
29 29
 
30
-  public function append($path, $data){
30
+  public function append($path, $data) {
31 31
     @$this->storage[$path] .= $data;
32 32
   }
33 33
 
34
-  public function move($old, $new){
35
-    if($this->exists($old)){
34
+  public function move($old, $new) {
35
+    if($this->exists($old)) {
36 36
       $this->storage[$new] = $this->storage[$old];
37 37
       unset($this->storage[$old]);
38 38
       return true;
39
-    } else return false;
39
+    } else {
40
+      return false;
41
+    }
40 42
   }
41 43
 
42
-  public function delete($path){
44
+  public function delete($path) {
43 45
     unset($this->storage[$path]);
44 46
     return true;
45 47
   }
46 48
 
47
-  public function search($pattern, $recursive=true){
49
+  public function search($pattern, $recursive=true) {
48 50
     $results = [];
49 51
     $rx_pattern = '('.strtr($pattern,['.'=>'\.','*'=>'.*','?'=>'.']).')Ai';
50 52
     foreach (array_keys($this->storage) as $path) {
51
-      if (preg_match($rx_pattern,$path)) $results[] = $path;
53
+      if (preg_match($rx_pattern,$path)) {
54
+        $results[] = $path;
55
+      }
52 56
     }
53 57
     return $results;
54 58
   }
Please login to merge, or discard this patch.
classes/Persistence.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
    */
136 136
   private static function persistenceLoadDefault($pk, $table, $options){
137 137
     if ( $data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1",[$pk]) ){
138
-       $obj = new static;
139
-       foreach ((array)$data as $key => $value) {
140
-         $obj->$key = $value;
141
-       }
142
-       return $obj;
143
-     } else {
144
-       return null;
145
-     }
138
+        $obj = new static;
139
+        foreach ((array)$data as $key => $value) {
140
+          $obj->$key = $value;
141
+        }
142
+        return $obj;
143
+      } else {
144
+        return null;
145
+      }
146 146
   }
147 147
 
148 148
   /**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
    * Private Standard Save Method
164 164
    */
165 165
   private function persistenceSaveDefault($table,$options){
166
-     return SQL::insertOrUpdate($table,array_filter((array)$this),$options['key']);
166
+      return SQL::insertOrUpdate($table,array_filter((array)$this),$options['key']);
167 167
   }
168 168
 
169 169
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
    * @param  mixed $options The options passed to the persistence layer.
21 21
    * @return mixed          All options array or a single value
22 22
    */
23
-  protected static function persistenceOptions($options=null){
24
-    static $_options = ['table'=>null,'key'=>'id'];
23
+  protected static function persistenceOptions($options = null) {
24
+    static $_options = ['table'=>null, 'key'=>'id'];
25 25
     if ($options === null) return $_options;
26 26
 
27 27
     if (is_array($options)) {
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
     } else {
33 33
       if (empty($_options['table'])) {
34 34
         $self = get_called_class();
35
-        if (defined("$self::_PRIMARY_KEY_")){
35
+        if (defined("$self::_PRIMARY_KEY_")) {
36 36
           $x = explode('.', $self::_PRIMARY_KEY_);
37 37
           $_options = [
38 38
             'table' => current($x),
39
-            'key'   => isset($x[1])?$x[1]:'id',
39
+            'key'   => isset($x[1]) ? $x[1] : 'id',
40 40
           ];
41 41
         } else {
42 42
           // User pluralized class name as default table
43
-          switch(substr($s = strtolower($self),-1)){
44
-              case 'y': $table = substr($s,0,-1).'ies'; break;
45
-              case 's': $table = substr($s,0,-1).'es';  break;
46
-              default:  $table = $s.'s'; break;
43
+          switch (substr($s = strtolower($self), -1)) {
44
+              case 'y': $table = substr($s, 0, -1).'ies';break;
45
+              case 's': $table = substr($s, 0, -1).'es';break;
46
+              default:  $table = $s.'s';break;
47 47
           }
48 48
           // Default ID
49 49
           $_options = [
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
    * @param  callable $callback The callback to use on model save
65 65
    * @return callable           Current save callback
66 66
    */
67
-  protected static function persistenceSave(callable $callback=null){
67
+  protected static function persistenceSave(callable $callback = null) {
68 68
     static $save_cb = null;
69 69
     return $callback ? $save_cb = $callback : $save_cb;
70 70
   }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
    * @param  callable $callback The callback to use on model load
78 78
    * @return callable           Current load callback
79 79
    */
80
-  protected static function persistenceLoad(callable $callback=null){
80
+  protected static function persistenceLoad(callable $callback = null) {
81 81
     static $retrieve_cb = null;
82 82
     return $callback ? $retrieve_cb = $callback : $retrieve_cb;
83 83
   }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
    * @param  array $options An associative array with options for the persistance layer.
93 93
    * @return void
94 94
    */
95
-  public static function persistOn($table, array $options=[]){
95
+  public static function persistOn($table, array $options = []) {
96 96
     $options['table'] = $table;
97 97
     static::persistenceOptions($options);
98 98
   }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
    * @param  callable $callback The callback to use on model save
104 104
    * @return void
105 105
    */
106
-  public static function onSave(callable $callback){
106
+  public static function onSave(callable $callback) {
107 107
     static::persistenceSave($callback);
108 108
   }
109 109
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
    * @param  callable $callback The callback to use on model load
113 113
    * @return void
114 114
    */
115
-  public static function onLoad(callable $callback){
115
+  public static function onLoad(callable $callback) {
116 116
     static::persistenceLoad($callback);
117 117
   }
118 118
 
@@ -120,23 +120,23 @@  discard block
 block discarded – undo
120 120
    * Load the model from the persistence layer
121 121
    * @return mixed The retrieved object
122 122
    */
123
-  public static function load($pk){
123
+  public static function load($pk) {
124 124
     $table = static::persistenceOptions('table');
125 125
     $cb    = static::persistenceLoad();
126 126
     $op    = static::persistenceOptions();
127 127
 
128 128
     // Use standard persistence on DB layer
129
-    return ( false == is_callable($cb) ) ?
130
-      static::persistenceLoadDefault($pk,$table,$op) : $cb($pk,$table,$op);
129
+    return (false == is_callable($cb)) ?
130
+      static::persistenceLoadDefault($pk, $table, $op) : $cb($pk, $table, $op);
131 131
   }
132 132
 
133 133
   /**
134 134
    * Private Standard Load Method
135 135
    */
136
-  private static function persistenceLoadDefault($pk, $table, $options){
137
-    if ( $data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1",[$pk]) ){
136
+  private static function persistenceLoadDefault($pk, $table, $options) {
137
+    if ($data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1", [$pk])) {
138 138
        $obj = new static;
139
-       foreach ((array)$data as $key => $value) {
139
+       foreach ((array) $data as $key => $value) {
140 140
          $obj->$key = $value;
141 141
        }
142 142
        return $obj;
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
    * Save the model to the persistence layer
150 150
    * @return mixed The results from the save callback. (default: lastInsertID)
151 151
    */
152
-  public function save(){
152
+  public function save() {
153 153
     $table  = static::persistenceOptions('table');
154 154
     $op     = static::persistenceOptions();
155 155
     $cb     = static::persistenceSave();
156 156
 
157 157
     // Use standard persistence on DB layer
158
-    $cb = $cb ? Closure::bind($cb, $this) : [$this,'persistenceSaveDefault'];
159
-    return $cb($table,$op);
158
+    $cb = $cb ? Closure::bind($cb, $this) : [$this, 'persistenceSaveDefault'];
159
+    return $cb($table, $op);
160 160
   }
161 161
 
162 162
   /**
163 163
    * Private Standard Save Method
164 164
    */
165
-  private function persistenceSaveDefault($table,$options){
166
-     return SQL::insertOrUpdate($table,array_filter((array)$this),$options['key']);
165
+  private function persistenceSaveDefault($table, $options) {
166
+     return SQL::insertOrUpdate($table, array_filter((array) $this), $options['key']);
167 167
   }
168 168
 
169 169
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,19 +20,23 @@  discard block
 block discarded – undo
20 20
    * @param  mixed $options The options passed to the persistence layer.
21 21
    * @return mixed          All options array or a single value
22 22
    */
23
-  protected static function persistenceOptions($options=null){
23
+  protected static function persistenceOptions($options=null) {
24 24
     static $_options = ['table'=>null,'key'=>'id'];
25
-    if ($options === null) return $_options;
25
+    if ($options === null) {
26
+      return $_options;
27
+    }
26 28
 
27 29
     if (is_array($options)) {
28 30
       foreach ($_options as $key => &$value) {
29
-        if (isset($options[$key])) $value = $options[$key];
31
+        if (isset($options[$key])) {
32
+          $value = $options[$key];
33
+        }
30 34
       }
31 35
       return $_options;
32 36
     } else {
33 37
       if (empty($_options['table'])) {
34 38
         $self = get_called_class();
35
-        if (defined("$self::_PRIMARY_KEY_")){
39
+        if (defined("$self::_PRIMARY_KEY_")) {
36 40
           $x = explode('.', $self::_PRIMARY_KEY_);
37 41
           $_options = [
38 42
             'table' => current($x),
@@ -40,7 +44,7 @@  discard block
 block discarded – undo
40 44
           ];
41 45
         } else {
42 46
           // User pluralized class name as default table
43
-          switch(substr($s = strtolower($self),-1)){
47
+          switch(substr($s = strtolower($self),-1)) {
44 48
               case 'y': $table = substr($s,0,-1).'ies'; break;
45 49
               case 's': $table = substr($s,0,-1).'es';  break;
46 50
               default:  $table = $s.'s'; break;
@@ -64,7 +68,7 @@  discard block
 block discarded – undo
64 68
    * @param  callable $callback The callback to use on model save
65 69
    * @return callable           Current save callback
66 70
    */
67
-  protected static function persistenceSave(callable $callback=null){
71
+  protected static function persistenceSave(callable $callback=null) {
68 72
     static $save_cb = null;
69 73
     return $callback ? $save_cb = $callback : $save_cb;
70 74
   }
@@ -77,7 +81,7 @@  discard block
 block discarded – undo
77 81
    * @param  callable $callback The callback to use on model load
78 82
    * @return callable           Current load callback
79 83
    */
80
-  protected static function persistenceLoad(callable $callback=null){
84
+  protected static function persistenceLoad(callable $callback=null) {
81 85
     static $retrieve_cb = null;
82 86
     return $callback ? $retrieve_cb = $callback : $retrieve_cb;
83 87
   }
@@ -92,7 +96,7 @@  discard block
 block discarded – undo
92 96
    * @param  array $options An associative array with options for the persistance layer.
93 97
    * @return void
94 98
    */
95
-  public static function persistOn($table, array $options=[]){
99
+  public static function persistOn($table, array $options=[]) {
96 100
     $options['table'] = $table;
97 101
     static::persistenceOptions($options);
98 102
   }
@@ -103,7 +107,7 @@  discard block
 block discarded – undo
103 107
    * @param  callable $callback The callback to use on model save
104 108
    * @return void
105 109
    */
106
-  public static function onSave(callable $callback){
110
+  public static function onSave(callable $callback) {
107 111
     static::persistenceSave($callback);
108 112
   }
109 113
 
@@ -112,7 +116,7 @@  discard block
 block discarded – undo
112 116
    * @param  callable $callback The callback to use on model load
113 117
    * @return void
114 118
    */
115
-  public static function onLoad(callable $callback){
119
+  public static function onLoad(callable $callback) {
116 120
     static::persistenceLoad($callback);
117 121
   }
118 122
 
@@ -120,7 +124,7 @@  discard block
 block discarded – undo
120 124
    * Load the model from the persistence layer
121 125
    * @return mixed The retrieved object
122 126
    */
123
-  public static function load($pk){
127
+  public static function load($pk) {
124 128
     $table = static::persistenceOptions('table');
125 129
     $cb    = static::persistenceLoad();
126 130
     $op    = static::persistenceOptions();
@@ -133,8 +137,8 @@  discard block
 block discarded – undo
133 137
   /**
134 138
    * Private Standard Load Method
135 139
    */
136
-  private static function persistenceLoadDefault($pk, $table, $options){
137
-    if ( $data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1",[$pk]) ){
140
+  private static function persistenceLoadDefault($pk, $table, $options) {
141
+    if ( $data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1",[$pk]) ) {
138 142
        $obj = new static;
139 143
        foreach ((array)$data as $key => $value) {
140 144
          $obj->$key = $value;
@@ -149,7 +153,7 @@  discard block
 block discarded – undo
149 153
    * Save the model to the persistence layer
150 154
    * @return mixed The results from the save callback. (default: lastInsertID)
151 155
    */
152
-  public function save(){
156
+  public function save() {
153 157
     $table  = static::persistenceOptions('table');
154 158
     $op     = static::persistenceOptions();
155 159
     $cb     = static::persistenceSave();
@@ -162,7 +166,7 @@  discard block
 block discarded – undo
162 166
   /**
163 167
    * Private Standard Save Method
164 168
    */
165
-  private function persistenceSaveDefault($table,$options){
169
+  private function persistenceSaveDefault($table,$options) {
166 170
      return SQL::insertOrUpdate($table,array_filter((array)$this),$options['key']);
167 171
   }
168 172
 
Please login to merge, or discard this patch.
classes/Token.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
     $encoded_payload = implode('.', [rtrim(strtr(base64_encode(json_encode([
18 18
         'typ' => 'JWT',
19 19
         'alg' => $algo,
20
-      ])), '+/', '-_'),'='),
21
-      rtrim(strtr(base64_encode(json_encode($payload)), '+/', '-_'),'='),
20
+      ])), '+/', '-_'), '='),
21
+      rtrim(strtr(base64_encode(json_encode($payload)), '+/', '-_'), '='),
22 22
     ]);
23
-    return $encoded_payload . '.' . static::sign($encoded_payload, $secret, $algo);
23
+    return $encoded_payload.'.'.static::sign($encoded_payload, $secret, $algo);
24 24
   }
25 25
 
26
-  public static function decode($jwt, $secret = null, $verify = true){
26
+  public static function decode($jwt, $secret = null, $verify = true) {
27 27
 
28
-    if (substr_count($jwt,'.') != 2) throw new \Exception('Token not valid');
28
+    if (substr_count($jwt, '.') != 2) throw new \Exception('Token not valid');
29 29
 
30 30
     list($encoded_header, $encoded_payload, $client_sig) = explode('.', $jwt);
31 31
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
       'HS256' => 'sha256',
54 54
     ];
55 55
     if (empty($algos[$algo])) throw new \Exception('Signing algorithm not supported');
56
-    return rtrim(strtr(base64_encode(hash_hmac($algos[$algo], $payload, $secret, true)), '+/', '-_'),'=');
56
+    return rtrim(strtr(base64_encode(hash_hmac($algos[$algo], $payload, $secret, true)), '+/', '-_'), '=');
57 57
   }
58 58
 
59 59
 }
Please login to merge, or discard this patch.
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,24 +23,31 @@  discard block
 block discarded – undo
23 23
     return $encoded_payload . '.' . static::sign($encoded_payload, $secret, $algo);
24 24
   }
25 25
 
26
-  public static function decode($jwt, $secret = null, $verify = true){
26
+  public static function decode($jwt, $secret = null, $verify = true) {
27 27
 
28
-    if (substr_count($jwt,'.') != 2) throw new \Exception('Token not valid');
28
+    if (substr_count($jwt,'.') != 2) {
29
+      throw new \Exception('Token not valid');
30
+    }
29 31
 
30 32
     list($encoded_header, $encoded_payload, $client_sig) = explode('.', $jwt);
31 33
 
32
-    if (null === ($payload = json_decode(base64_decode(strtr($encoded_payload, '-_', '+/')))))
33
-      throw new \Exception('Invalid encoding');
34
+    if (null === ($payload = json_decode(base64_decode(strtr($encoded_payload, '-_', '+/'))))) {
35
+          throw new \Exception('Invalid encoding');
36
+    }
34 37
 
35 38
 
36 39
     if ($verify) {
37
-      if (null === ($header = json_decode(base64_decode(strtr($encoded_header, '-_', '+/')))))
38
-        throw new \Exception('Invalid encoding');
40
+      if (null === ($header = json_decode(base64_decode(strtr($encoded_header, '-_', '+/'))))) {
41
+              throw new \Exception('Invalid encoding');
42
+      }
39 43
 
40
-      if (empty($header->alg)) throw new \Exception('Invalid encoding');
44
+      if (empty($header->alg)) {
45
+        throw new \Exception('Invalid encoding');
46
+      }
41 47
 
42
-      if ($client_sig != static::sign("$encoded_header.$encoded_payload", $secret, $header->alg))
43
-        throw new \Exception('Token verification failed');
48
+      if ($client_sig != static::sign("$encoded_header.$encoded_payload", $secret, $header->alg)) {
49
+              throw new \Exception('Token verification failed');
50
+      }
44 51
     }
45 52
 
46 53
     return $payload;
@@ -52,7 +59,9 @@  discard block
 block discarded – undo
52 59
       'HS384' => 'sha384',
53 60
       'HS256' => 'sha256',
54 61
     ];
55
-    if (empty($algos[$algo])) throw new \Exception('Signing algorithm not supported');
62
+    if (empty($algos[$algo])) {
63
+      throw new \Exception('Signing algorithm not supported');
64
+    }
56 65
     return rtrim(strtr(base64_encode(hash_hmac($algos[$algo], $payload, $secret, true)), '+/', '-_'),'=');
57 66
   }
58 67
 
Please login to merge, or discard this patch.
classes/Event.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,40 +15,40 @@
 block discarded – undo
15 15
 
16 16
     protected static $_listeners = [];
17 17
 
18
-    public static function on($name,callable $listener){
18
+    public static function on($name, callable $listener) {
19 19
         static::$_listeners[$name][] = $listener;
20 20
     }
21 21
 
22
-    public static function single($name,callable $listener){
22
+    public static function single($name, callable $listener) {
23 23
         static::$_listeners[$name] = [$listener];
24 24
     }
25 25
 
26
-    public static function off($name,callable $listener = null){
27
-        if($listener === null) {
26
+    public static function off($name, callable $listener = null) {
27
+        if ($listener === null) {
28 28
             unset(static::$_listeners[$name]);
29 29
         } else {
30
-            if ($idx = array_search($listener,static::$_listeners[$name],true))
30
+            if ($idx = array_search($listener, static::$_listeners[$name], true))
31 31
                 unset(static::$_listeners[$name][$idx]);
32 32
         }
33 33
     }
34 34
 
35
-    public static function alias($source,$alias){
36
-        static::$_listeners[$alias] =& static::$_listeners[$source];
35
+    public static function alias($source, $alias) {
36
+        static::$_listeners[$alias] = & static::$_listeners[$source];
37 37
     }
38 38
 
39
-    public static function trigger($name){
40
-        if (false === empty(static::$_listeners[$name])){
39
+    public static function trigger($name) {
40
+        if (false === empty(static::$_listeners[$name])) {
41 41
             $args = func_get_args();
42 42
             array_shift($args);
43 43
             $results = [];
44 44
             foreach (static::$_listeners[$name] as $listener) {
45
-                $results[] = call_user_func_array($listener,$args);
45
+                $results[] = call_user_func_array($listener, $args);
46 46
             }
47 47
             return $results;
48 48
         };
49 49
     }
50 50
 
51
-    public static function triggerOnce($name){
51
+    public static function triggerOnce($name) {
52 52
         $res = static::trigger($name);
53 53
         unset(static::$_listeners[$name]);
54 54
         return $res;
Please login to merge, or discard this patch.
Braces   +10 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,29 +15,30 @@  discard block
 block discarded – undo
15 15
 
16 16
     protected static $_listeners = [];
17 17
 
18
-    public static function on($name,callable $listener){
18
+    public static function on($name,callable $listener) {
19 19
         static::$_listeners[$name][] = $listener;
20 20
     }
21 21
 
22
-    public static function single($name,callable $listener){
22
+    public static function single($name,callable $listener) {
23 23
         static::$_listeners[$name] = [$listener];
24 24
     }
25 25
 
26
-    public static function off($name,callable $listener = null){
26
+    public static function off($name,callable $listener = null) {
27 27
         if($listener === null) {
28 28
             unset(static::$_listeners[$name]);
29 29
         } else {
30
-            if ($idx = array_search($listener,static::$_listeners[$name],true))
31
-                unset(static::$_listeners[$name][$idx]);
30
+            if ($idx = array_search($listener,static::$_listeners[$name],true)) {
31
+                            unset(static::$_listeners[$name][$idx]);
32
+            }
32 33
         }
33 34
     }
34 35
 
35
-    public static function alias($source,$alias){
36
+    public static function alias($source,$alias) {
36 37
         static::$_listeners[$alias] =& static::$_listeners[$source];
37 38
     }
38 39
 
39
-    public static function trigger($name){
40
-        if (false === empty(static::$_listeners[$name])){
40
+    public static function trigger($name) {
41
+        if (false === empty(static::$_listeners[$name])) {
41 42
             $args = func_get_args();
42 43
             array_shift($args);
43 44
             $results = [];
@@ -48,7 +49,7 @@  discard block
 block discarded – undo
48 49
         };
49 50
     }
50 51
 
51
-    public static function triggerOnce($name){
52
+    public static function triggerOnce($name) {
52 53
         $res = static::trigger($name);
53 54
         unset(static::$_listeners[$name]);
54 55
         return $res;
Please login to merge, or discard this patch.