Completed
Push — master ( 1011bb...99713d )
by Stefano
05:07
created
classes/Loader.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
 class Loader {
14 14
     protected static $paths = [];
15 15
     
16
-    public static function addPath($path,$name=null){
16
+    public static function addPath($path, $name = null) {
17 17
         static::$paths[$path] = $name;
18 18
     }
19 19
 
20
-    public static function register(){
20
+    public static function register() {
21 21
         ini_set('unserialize_callback_func', 'spl_autoload_call');
22
-        spl_autoload_register(function($class){
23
-            $cfile = strtr($class,'_\\','//') . '.php';
22
+        spl_autoload_register(function($class) {
23
+            $cfile = strtr($class, '_\\', '//').'.php';
24 24
             foreach (static::$paths as $path => $v) {
25
-                $file = rtrim($path,'/').'/'.$cfile;
26
-                if(is_file($file)) return include($file);
25
+                $file = rtrim($path, '/').'/'.$cfile;
26
+                if (is_file($file)) return include($file);
27 27
             }
28 28
             return false;
29
-        },false,true);
29
+        },false, true);
30 30
     }
31 31
     
32 32
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,17 +13,19 @@
 block discarded – undo
13 13
 class Loader {
14 14
     protected static $paths = [];
15 15
     
16
-    public static function addPath($path,$name=null){
16
+    public static function addPath($path,$name=null) {
17 17
         static::$paths[$path] = $name;
18 18
     }
19 19
 
20
-    public static function register(){
20
+    public static function register() {
21 21
         ini_set('unserialize_callback_func', 'spl_autoload_call');
22
-        spl_autoload_register(function($class){
22
+        spl_autoload_register(function($class) {
23 23
             $cfile = strtr($class,'_\\','//') . '.php';
24 24
             foreach (static::$paths as $path => $v) {
25 25
                 $file = rtrim($path,'/').'/'.$cfile;
26
-                if(is_file($file)) return include($file);
26
+                if(is_file($file)) {
27
+                  return include($file);
28
+                }
27 29
             }
28 30
             return false;
29 31
         },false,true);
Please login to merge, or discard this patch.
classes/Model.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
     }
30 30
 
31 31
     public static function all($page=1,$limit=-1){
32
-    		$offset = max(1,$page)-1;
32
+        $offset = max(1,$page)-1;
33 33
         return static::where($limit < 1 ? "" : "1 limit $limit offset $offset");
34 34
     }
35 35
 
36 36
     public function primaryKey(){
37
-    	$self    = get_called_class();
37
+      $self    = get_called_class();
38 38
       $key     = $self::persistenceOptions('key');
39 39
       return $this->$key;
40 40
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public static function create(array $data){
43 43
         $tmp = new static;
44 44
         foreach ($data as $key => $value) {
45
-           $tmp->$key = $value;
45
+            $tmp->$key = $value;
46 46
         }
47 47
         $tmp->save();
48 48
         return $tmp;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@
 block discarded – undo
13 13
 abstract class Model {
14 14
     use Module, Persistence;
15 15
 
16
-    public static function where($where_sql = false){
16
+    public static function where($where_sql = false) {
17 17
         // Forward persistence calls to caller class, not Model
18 18
         $self    = get_called_class();
19 19
         $table   = $self::persistenceOptions('table');
20 20
         $key     = $self::persistenceOptions('key');
21 21
 
22
-        $sql = "select $key from $table" . ($where_sql ? " where $where_sql" : '');
22
+        $sql = "select $key from $table".($where_sql ? " where $where_sql" : '');
23 23
 
24 24
         $results = [];
25
-        SQL::each($sql, function($row) use ($self,&$results,$key){
25
+        SQL::each($sql, function($row) use ($self, &$results, $key){
26 26
             $results[] = $self::load($row->$key);
27 27
         });
28 28
         return $results;
29 29
     }
30 30
 
31
-    public static function all($page=1,$limit=-1){
32
-    		$offset = max(1,$page)-1;
31
+    public static function all($page = 1, $limit = -1) {
32
+    		$offset = max(1, $page) - 1;
33 33
         return static::where($limit < 1 ? "" : "1 limit $limit offset $offset");
34 34
     }
35 35
 
36
-    public function primaryKey(){
37
-    	$self    = get_called_class();
38
-      $key     = $self::persistenceOptions('key');
36
+    public function primaryKey() {
37
+    	$self = get_called_class();
38
+      $key = $self::persistenceOptions('key');
39 39
       return $this->$key;
40 40
     }
41 41
 
42
-    public static function create(array $data){
42
+    public static function create(array $data) {
43 43
         $tmp = new static;
44 44
         foreach ($data as $key => $value) {
45 45
            $tmp->$key = $value;
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
 abstract class Model {
14 14
     use Module, Persistence;
15 15
 
16
-    public static function where($where_sql = false){
16
+    public static function where($where_sql = false) {
17 17
         // Forward persistence calls to caller class, not Model
18 18
         $self    = get_called_class();
19 19
         $table   = $self::persistenceOptions('table');
@@ -22,24 +22,24 @@  discard block
 block discarded – undo
22 22
         $sql = "select $key from $table" . ($where_sql ? " where $where_sql" : '');
23 23
 
24 24
         $results = [];
25
-        SQL::each($sql, function($row) use ($self,&$results,$key){
25
+        SQL::each($sql, function($row) use ($self,&$results,$key) {
26 26
             $results[] = $self::load($row->$key);
27 27
         });
28 28
         return $results;
29 29
     }
30 30
 
31
-    public static function all($page=1,$limit=-1){
31
+    public static function all($page=1,$limit=-1) {
32 32
     		$offset = max(1,$page)-1;
33 33
         return static::where($limit < 1 ? "" : "1 limit $limit offset $offset");
34 34
     }
35 35
 
36
-    public function primaryKey(){
36
+    public function primaryKey() {
37 37
     	$self    = get_called_class();
38 38
       $key     = $self::persistenceOptions('key');
39 39
       return $this->$key;
40 40
     }
41 41
 
42
-    public static function create(array $data){
42
+    public static function create(array $data) {
43 43
         $tmp = new static;
44 44
         foreach ($data as $key => $value) {
45 45
            $tmp->$key = $value;
Please login to merge, or discard this patch.
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,7 +20,7 @@  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 = [];
25 25
 
26 26
     if ($options === null) return $_options;
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
     } else {
30 30
       if (empty($_options['table'])) {
31 31
         $self = get_called_class();
32
-        if (defined("$self::_PRIMARY_KEY_")){
32
+        if (defined("$self::_PRIMARY_KEY_")) {
33 33
           $x = explode('.', $self::_PRIMARY_KEY_);
34 34
           $_options = [
35 35
             'table' => current($x),
36
-            'key'   => isset($x[1])?$x[1]:'id',
36
+            'key'   => isset($x[1]) ? $x[1] : 'id',
37 37
           ];
38 38
         } else {
39 39
           // User pluralized class name as default table
40
-          switch(substr($s = strtolower($self),-1)){
41
-              case 'y': $table = substr($s,0,-1).'ies'; break;
42
-              case 's': $table = substr($s,0,-1).'es';  break;
43
-              default:  $table = $s.'s'; break;
40
+          switch (substr($s = strtolower($self), -1)) {
41
+              case 'y': $table = substr($s, 0, -1).'ies';break;
42
+              case 's': $table = substr($s, 0, -1).'es';break;
43
+              default:  $table = $s.'s';break;
44 44
           }
45 45
           // Default ID
46 46
           $_options = [
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
    * @param  callable $callback The callback to use on model save
62 62
    * @return callable           Current save callback
63 63
    */
64
-  protected static function persistenceSave(callable $callback=null){
64
+  protected static function persistenceSave(callable $callback = null) {
65 65
     static $save_cb = null;
66 66
     return $callback ? $save_cb = $callback : $save_cb;
67 67
   }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
    * @param  callable $callback The callback to use on model load
75 75
    * @return callable           Current load callback
76 76
    */
77
-  protected static function persistenceLoad(callable $callback=null){
77
+  protected static function persistenceLoad(callable $callback = null) {
78 78
     static $retrieve_cb = null;
79 79
     return $callback ? $retrieve_cb = $callback : $retrieve_cb;
80 80
   }
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
    * @param  array $options An associative array with options for the persistance layer.
90 90
    * @return void
91 91
    */
92
-  public static function persistOn($table, array $options=[]){
93
-    $options = array_merge($options,[
92
+  public static function persistOn($table, array $options = []) {
93
+    $options = array_merge($options, [
94 94
       'key' => 'id'
95 95
     ]);
96 96
     $options['table'] = $table;
@@ -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   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,16 +20,18 @@  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 = [];
25 25
 
26
-    if ($options === null) return $_options;
26
+    if ($options === null) {
27
+      return $_options;
28
+    }
27 29
     if (is_array($options)) {
28 30
       return $_options = $options;
29 31
     } else {
30 32
       if (empty($_options['table'])) {
31 33
         $self = get_called_class();
32
-        if (defined("$self::_PRIMARY_KEY_")){
34
+        if (defined("$self::_PRIMARY_KEY_")) {
33 35
           $x = explode('.', $self::_PRIMARY_KEY_);
34 36
           $_options = [
35 37
             'table' => current($x),
@@ -37,7 +39,7 @@  discard block
 block discarded – undo
37 39
           ];
38 40
         } else {
39 41
           // User pluralized class name as default table
40
-          switch(substr($s = strtolower($self),-1)){
42
+          switch(substr($s = strtolower($self),-1)) {
41 43
               case 'y': $table = substr($s,0,-1).'ies'; break;
42 44
               case 's': $table = substr($s,0,-1).'es';  break;
43 45
               default:  $table = $s.'s'; break;
@@ -61,7 +63,7 @@  discard block
 block discarded – undo
61 63
    * @param  callable $callback The callback to use on model save
62 64
    * @return callable           Current save callback
63 65
    */
64
-  protected static function persistenceSave(callable $callback=null){
66
+  protected static function persistenceSave(callable $callback=null) {
65 67
     static $save_cb = null;
66 68
     return $callback ? $save_cb = $callback : $save_cb;
67 69
   }
@@ -74,7 +76,7 @@  discard block
 block discarded – undo
74 76
    * @param  callable $callback The callback to use on model load
75 77
    * @return callable           Current load callback
76 78
    */
77
-  protected static function persistenceLoad(callable $callback=null){
79
+  protected static function persistenceLoad(callable $callback=null) {
78 80
     static $retrieve_cb = null;
79 81
     return $callback ? $retrieve_cb = $callback : $retrieve_cb;
80 82
   }
@@ -89,7 +91,7 @@  discard block
 block discarded – undo
89 91
    * @param  array $options An associative array with options for the persistance layer.
90 92
    * @return void
91 93
    */
92
-  public static function persistOn($table, array $options=[]){
94
+  public static function persistOn($table, array $options=[]) {
93 95
     $options = array_merge($options,[
94 96
       'key' => 'id'
95 97
     ]);
@@ -103,7 +105,7 @@  discard block
 block discarded – undo
103 105
    * @param  callable $callback The callback to use on model save
104 106
    * @return void
105 107
    */
106
-  public static function onSave(callable $callback){
108
+  public static function onSave(callable $callback) {
107 109
     static::persistenceSave($callback);
108 110
   }
109 111
 
@@ -112,7 +114,7 @@  discard block
 block discarded – undo
112 114
    * @param  callable $callback The callback to use on model load
113 115
    * @return void
114 116
    */
115
-  public static function onLoad(callable $callback){
117
+  public static function onLoad(callable $callback) {
116 118
     static::persistenceLoad($callback);
117 119
   }
118 120
 
@@ -120,7 +122,7 @@  discard block
 block discarded – undo
120 122
    * Load the model from the persistence layer
121 123
    * @return mixed The retrieved object
122 124
    */
123
-  public static function load($pk){
125
+  public static function load($pk) {
124 126
     $table = static::persistenceOptions('table');
125 127
     $cb    = static::persistenceLoad();
126 128
     $op    = static::persistenceOptions();
@@ -133,8 +135,8 @@  discard block
 block discarded – undo
133 135
   /**
134 136
    * Private Standard Load Method
135 137
    */
136
-  private static function persistenceLoadDefault($pk, $table, $options){
137
-    if ( $data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1",[$pk]) ){
138
+  private static function persistenceLoadDefault($pk, $table, $options) {
139
+    if ( $data = SQL::single("SELECT * FROM $table WHERE {$options['key']}=? LIMIT 1",[$pk]) ) {
138 140
        $obj = new static;
139 141
        foreach ((array)$data as $key => $value) {
140 142
          $obj->$key = $value;
@@ -149,7 +151,7 @@  discard block
 block discarded – undo
149 151
    * Save the model to the persistence layer
150 152
    * @return mixed The results from the save callback. (default: lastInsertID)
151 153
    */
152
-  public function save(){
154
+  public function save() {
153 155
     $table  = static::persistenceOptions('table');
154 156
     $op     = static::persistenceOptions();
155 157
     $cb     = static::persistenceSave();
@@ -162,7 +164,7 @@  discard block
 block discarded – undo
162 164
   /**
163 165
    * Private Standard Save Method
164 166
    */
165
-  private function persistenceSaveDefault($table,$options){
167
+  private function persistenceSaveDefault($table,$options) {
166 168
      return SQL::insertOrUpdate($table,array_filter((array)$this),$options['key']);
167 169
   }
168 170
 
Please login to merge, or discard this patch.