Completed
Push — master ( 1901f0...da0657 )
by Stefano
03:01
created
classes/URL.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,27 +21,27 @@
 block discarded – undo
21 21
             $query     = [],
22 22
             $fragment  = false;
23 23
 
24
-  public function __construct($url=''){
24
+  public function __construct($url = '') {
25 25
     if (empty($url) || !is_string($url)) return;
26
-    $tmp_url      = (strpos($url, '://') === false) ? "..N..://$url" : $url;
26
+    $tmp_url = (strpos($url, '://') === false) ? "..N..://$url" : $url;
27 27
     if (mb_detect_encoding($tmp_url, 'UTF-8', true) || ($parsed = parse_url($tmp_url)) === false) {
28 28
       preg_match('(^((?P<scheme>[^:/?#]+):(//))?((\\3|//)?(?:(?P<user>[^:]+):(?P<pass>[^@]+)@)?(?P<host>[^/?:#]*))(:(?P<port>\\d+))?(?P<path>[^?#]*)(\\?(?P<query>[^#]*))?(#(?P<fragment>.*))?)u', $tmp_url, $parsed);
29 29
     }
30
-    foreach($parsed as $k => $v) if(isset($this->$k)) $this->$k = $v;
30
+    foreach ($parsed as $k => $v) if (isset($this->$k)) $this->$k = $v;
31 31
     if ($this->scheme == '..N..') $this->scheme = null;
32 32
     if (!empty($this->query)) {
33 33
       parse_str($this->query, $this->query);
34 34
     }
35 35
   }
36 36
 
37
-  public function __toString(){
37
+  public function __toString() {
38 38
     $d = [];
39 39
     if ($this->scheme)         $d[] = "{$this->scheme}://";
40
-    if ($this->user)           $d[] = "{$this->user}" . (empty($this->pass)?'':":{$this->pass}") . "@";
40
+    if ($this->user)           $d[] = "{$this->user}".(empty($this->pass) ? '' : ":{$this->pass}")."@";
41 41
     if ($this->host)           $d[] = "{$this->host}";
42 42
     if ($this->port)           $d[] = ":{$this->port}";
43
-    if ($this->path)           $d[] = "/" . ltrim($this->path,"/");
44
-    if (!empty($this->query))  $d[] = "?" . http_build_query($this->query);
43
+    if ($this->path)           $d[] = "/".ltrim($this->path, "/");
44
+    if (!empty($this->query))  $d[] = "?".http_build_query($this->query);
45 45
     if ($this->fragment)       $d[] = "#{$this->fragment}";
46 46
     return implode('', $d);
47 47
   }
Please login to merge, or discard this patch.
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,28 +21,48 @@
 block discarded – undo
21 21
             $query     = [],
22 22
             $fragment  = false;
23 23
 
24
-  public function __construct($url=''){
25
-    if (empty($url) || !is_string($url)) return;
24
+  public function __construct($url='') {
25
+    if (empty($url) || !is_string($url)) {
26
+      return;
27
+    }
26 28
     $tmp_url      = (strpos($url, '://') === false) ? "..N..://$url" : $url;
27 29
     if (mb_detect_encoding($tmp_url, 'UTF-8', true) || ($parsed = parse_url($tmp_url)) === false) {
28 30
       preg_match('(^((?P<scheme>[^:/?#]+):(//))?((\\3|//)?(?:(?P<user>[^:]+):(?P<pass>[^@]+)@)?(?P<host>[^/?:#]*))(:(?P<port>\\d+))?(?P<path>[^?#]*)(\\?(?P<query>[^#]*))?(#(?P<fragment>.*))?)u', $tmp_url, $parsed);
29 31
     }
30
-    foreach($parsed as $k => $v) if(isset($this->$k)) $this->$k = $v;
31
-    if ($this->scheme == '..N..') $this->scheme = null;
32
+    foreach($parsed as $k => $v) if(isset($this->$k)) {
33
+      $this->$k = $v;
34
+    }
35
+    if ($this->scheme == '..N..') {
36
+      $this->scheme = null;
37
+    }
32 38
     if (!empty($this->query)) {
33 39
       parse_str($this->query, $this->query);
34 40
     }
35 41
   }
36 42
 
37
-  public function __toString(){
43
+  public function __toString() {
38 44
     $d = [];
39
-    if ($this->scheme)         $d[] = "{$this->scheme}://";
40
-    if ($this->user)           $d[] = "{$this->user}" . (empty($this->pass)?'':":{$this->pass}") . "@";
41
-    if ($this->host)           $d[] = "{$this->host}";
42
-    if ($this->port)           $d[] = ":{$this->port}";
43
-    if ($this->path)           $d[] = "/" . ltrim($this->path,"/");
44
-    if (!empty($this->query))  $d[] = "?" . http_build_query($this->query);
45
-    if ($this->fragment)       $d[] = "#{$this->fragment}";
45
+    if ($this->scheme) {
46
+      $d[] = "{$this->scheme}://";
47
+    }
48
+    if ($this->user) {
49
+      $d[] = "{$this->user}" . (empty($this->pass)?'':":{$this->pass}") . "@";
50
+    }
51
+    if ($this->host) {
52
+      $d[] = "{$this->host}";
53
+    }
54
+    if ($this->port) {
55
+      $d[] = ":{$this->port}";
56
+    }
57
+    if ($this->path) {
58
+      $d[] = "/" . ltrim($this->path,"/");
59
+    }
60
+    if (!empty($this->query)) {
61
+      $d[] = "?" . http_build_query($this->query);
62
+    }
63
+    if ($this->fragment) {
64
+      $d[] = "#{$this->fragment}";
65
+    }
46 66
     return implode('', $d);
47 67
   }
48 68
 
Please login to merge, or discard this patch.
classes/Check.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
   use Module;
15 15
 
16 16
   protected static $methods = [],
17
-                   $errors  = [];
17
+                    $errors  = [];
18 18
   public static    $data    = [];
19 19
 
20 20
   public static function valid($rules, $data){
@@ -103,105 +103,105 @@  discard block
 block discarded – undo
103 103
     'required' => [
104 104
       'validate' => function($value) {
105 105
           return (is_numeric($value) && $value==0) || !empty($value);
106
-       },
107
-       'message' => "This value cannot be empty.",
106
+        },
107
+        'message' => "This value cannot be empty.",
108 108
     ],
109 109
 
110 110
     'alphanumeric' => [
111 111
       'validate' => function($value) {
112
-         return (bool)preg_match('/^[0-9a-zA-Z]+$/',$value);
112
+          return (bool)preg_match('/^[0-9a-zA-Z]+$/',$value);
113 113
       },
114 114
       'message' => "Value must be alphanumeric.",
115 115
     ],
116 116
 
117 117
     'numeric' => [
118 118
       'validate' => function($value) {
119
-         return (bool)preg_match('/^\d+$/',$value);
119
+          return (bool)preg_match('/^\d+$/',$value);
120 120
       },
121 121
       'message' => "Value must be numeric.",
122 122
     ],
123 123
 
124 124
     'email' => [
125 125
       'validate' => function($value) {
126
-         return (bool)filter_var($value, FILTER_VALIDATE_EMAIL);
126
+          return (bool)filter_var($value, FILTER_VALIDATE_EMAIL);
127 127
       },
128 128
       'message' => "This is not a valid email.",
129 129
     ],
130 130
 
131 131
     'url' => [
132 132
       'validate' => function($value) {
133
-         return (bool)filter_var($value, FILTER_VALIDATE_URL);
133
+          return (bool)filter_var($value, FILTER_VALIDATE_URL);
134 134
       },
135 135
       'message' => "This is not a valid URL.",
136 136
     ],
137 137
 
138 138
     'max' => [
139 139
       'validate' => function($value,$max) {
140
-       return $value<=$max ? true : false;
140
+        return $value<=$max ? true : false;
141 141
     },
142 142
       'message' => "Value must be less than {{arg_1}}.",
143 143
     ],
144 144
 
145 145
     'min' => [
146 146
       'validate' => function($value,$min) {
147
-         return $value >= $min;
147
+          return $value >= $min;
148 148
       },
149 149
       'message' => "Value must be greater than {{arg_1}}.",
150 150
     ],
151 151
 
152 152
     'range' => [
153 153
       'validate' => function($value,$min,$max) {
154
-         return ( $value >= $min ) && ( $value <= $max );
154
+          return ( $value >= $min ) && ( $value <= $max );
155 155
       },
156 156
       'message' => "This value must be in [{{arg_1}},{{arg_2}}] range.",
157 157
     ],
158 158
 
159 159
     'words' => [
160 160
       'validate' => function($value,$max) {
161
-         return str_word_count($value) <= $max;
161
+          return str_word_count($value) <= $max;
162 162
       },
163 163
       'message' => "Too many words, max count is {{arg_1}}.",
164 164
     ],
165 165
 
166 166
     'length' => [
167 167
       'validate' => function($value,$length) {
168
-         return strlen($value) == $length;
168
+          return strlen($value) == $length;
169 169
       },
170 170
       'message' => "This value must be {{arg_1}} characters.",
171 171
     ],
172 172
 
173 173
     'min_length' => [
174 174
       'validate' => function($value,$min) {
175
-         return strlen($value) >= $min;
175
+          return strlen($value) >= $min;
176 176
       },
177 177
       'message' => "Too few characters, min count is {{arg_1}}.",
178 178
     ],
179 179
 
180 180
     'max_length' => [
181 181
       'validate' => function($value,$max) {
182
-         return strlen($value) <= $max;
182
+          return strlen($value) <= $max;
183 183
       },
184 184
       'message' => "Too many characters, max count is {{arg_1}}.",
185 185
     ],
186 186
 
187 187
     'true' => [
188 188
       'validate' => function($value) {
189
-         return (bool)$value;
189
+          return (bool)$value;
190 190
       },
191 191
       'message' => "This value must be true.",
192 192
     ],
193 193
 
194 194
     'false' => [
195 195
       'validate' => function($value) {
196
-         return !$value;
196
+          return !$value;
197 197
       },
198 198
       'message' => "This value must be false.",
199 199
     ],
200 200
 
201 201
     'same_as' => [
202 202
       'validate' => function($value,$fieldname) {
203
-       $x = isset(Check::$data[$fieldname]) ? Check::$data[$fieldname] : '';
204
-         return $value == $x;
203
+        $x = isset(Check::$data[$fieldname]) ? Check::$data[$fieldname] : '';
204
+          return $value == $x;
205 205
       },
206 206
       'message' => "Field must be equal to {{arg_1}}.",
207 207
     ],
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -17,46 +17,46 @@  discard block
 block discarded – undo
17 17
                    $errors  = [];
18 18
   public static    $data    = [];
19 19
 
20
-  public static function valid($rules, $data){
20
+  public static function valid($rules, $data) {
21 21
     static::$errors = [];
22 22
     Event::triggerOnce('core.check.init');
23
-    self::$data = ($data = (array)$data);
23
+    self::$data = ($data = (array) $data);
24 24
 
25
-    foreach ((array)$rules as $field_name => $rule) {
25
+    foreach ((array) $rules as $field_name => $rule) {
26 26
 
27 27
       $current = isset($data[$field_name]) ? $data[$field_name] : null;
28 28
 
29
-      if (is_callable($rule)){
30
-        static::$errors[$field_name] = call_user_func($rule,$current);
29
+      if (is_callable($rule)) {
30
+        static::$errors[$field_name] = call_user_func($rule, $current);
31 31
         continue;
32 32
       } elseif (is_string($rule)) {
33 33
         $current_rules = array_flip(preg_split('/\s*\|\s*/', $rule));
34 34
       } else {
35
-        $current_rules = (array)$rule;
35
+        $current_rules = (array) $rule;
36 36
       }
37 37
 
38 38
       static::$errors[$field_name] = true;
39 39
 
40
-      foreach($current_rules as $method => $message) {
40
+      foreach ($current_rules as $method => $message) {
41 41
 
42 42
         $meth_name = strtok($method, ':');
43 43
         $opts      = strtok(':') ?: '';
44 44
         $opts      = $opts ? json_decode("[$opts]") : [];
45 45
         $meth_opts = $opts ? array_merge([$current], $opts) : [$current];
46 46
 
47
-        if ( static::$errors[$field_name] !== true ) continue 2;
47
+        if (static::$errors[$field_name] !== true) continue 2;
48 48
 
49 49
         if (empty(static::$methods[$meth_name])) {
50 50
           static::$errors[$field_name] = true;
51 51
         } else {
52
-          if (call_user_func_array(static::$methods[$meth_name]->validate,$meth_opts)){
52
+          if (call_user_func_array(static::$methods[$meth_name]->validate, $meth_opts)) {
53 53
             static::$errors[$field_name] = true;
54 54
           } else {
55 55
             $arg = [];
56 56
             foreach ($meth_opts as $key => $value) {
57 57
               $arg["arg_$key"] = $value;
58 58
             }
59
-            static::$errors[$field_name] = Text::render(static::$methods[$meth_name]->message,$arg);
59
+            static::$errors[$field_name] = Text::render(static::$methods[$meth_name]->message, $arg);
60 60
           }
61 61
         }
62 62
       }
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
     self::$data = [];
66 66
 
67 67
     // Clean non-errors
68
-    static::$errors = array_filter(static::$errors,function($v){
68
+    static::$errors = array_filter(static::$errors, function($v) {
69 69
       return $v !== true;
70 70
     });
71 71
 
72 72
     return empty(static::$errors);
73 73
   }
74 74
 
75
-  public static function method($name, $definition = null){
75
+  public static function method($name, $definition = null) {
76 76
     if (is_array($name)) {
77
-      foreach ($name as $method_name => $method_definition){
77
+      foreach ($name as $method_name => $method_definition) {
78 78
         if (is_callable($method_definition)) $method_definition = ['validate' => $method_definition];
79 79
         if (empty($method_definition['validate']) || !is_callable($method_definition['validate'])) continue;
80 80
         $method_definition['key']      = "core.check.error.$method_name";
81
-        $method_definition['message']  = Filter::with($method_definition['key'],@$method_definition['message']?:'Field not valid.');
82
-        static::$methods[$method_name] = (object)$method_definition;
81
+        $method_definition['message']  = Filter::with($method_definition['key'], @$method_definition['message'] ?: 'Field not valid.');
82
+        static::$methods[$method_name] = (object) $method_definition;
83 83
       }
84 84
     } else {
85 85
       if (is_callable($definition)) $definition = ['validate' => $definition];
86 86
       if (empty($definition['validate']) || !is_callable($definition['validate'])) return;
87 87
       $methods['key']         = "core.check.error.$name";
88
-      $methods['message']     = Filter::with($methods['key'],@$methods['message']?:'Field not valid.');
89
-      static::$methods[$name] = (object)$definition;
88
+      $methods['message']     = Filter::with($methods['key'], @$methods['message'] ?: 'Field not valid.');
89
+      static::$methods[$name] = (object) $definition;
90 90
     }
91 91
   }
92 92
 
@@ -96,89 +96,89 @@  discard block
 block discarded – undo
96 96
 
97 97
 }
98 98
 
99
-Event::on('core.check.init',function(){
99
+Event::on('core.check.init', function() {
100 100
 
101 101
   Check::method([
102 102
 
103 103
     'required' => [
104 104
       'validate' => function($value) {
105
-          return (is_numeric($value) && $value==0) || !empty($value);
105
+          return (is_numeric($value) && $value == 0) || !empty($value);
106 106
        },
107 107
        'message' => "This value cannot be empty.",
108 108
     ],
109 109
 
110 110
     'alphanumeric' => [
111 111
       'validate' => function($value) {
112
-         return (bool)preg_match('/^[0-9a-zA-Z]+$/',$value);
112
+         return (bool) preg_match('/^[0-9a-zA-Z]+$/', $value);
113 113
       },
114 114
       'message' => "Value must be alphanumeric.",
115 115
     ],
116 116
 
117 117
     'numeric' => [
118 118
       'validate' => function($value) {
119
-         return (bool)preg_match('/^\d+$/',$value);
119
+         return (bool) preg_match('/^\d+$/', $value);
120 120
       },
121 121
       'message' => "Value must be numeric.",
122 122
     ],
123 123
 
124 124
     'email' => [
125 125
       'validate' => function($value) {
126
-         return (bool)filter_var($value, FILTER_VALIDATE_EMAIL);
126
+         return (bool) filter_var($value, FILTER_VALIDATE_EMAIL);
127 127
       },
128 128
       'message' => "This is not a valid email.",
129 129
     ],
130 130
 
131 131
     'url' => [
132 132
       'validate' => function($value) {
133
-         return (bool)filter_var($value, FILTER_VALIDATE_URL);
133
+         return (bool) filter_var($value, FILTER_VALIDATE_URL);
134 134
       },
135 135
       'message' => "This is not a valid URL.",
136 136
     ],
137 137
 
138 138
     'max' => [
139
-      'validate' => function($value,$max) {
140
-       return $value<=$max ? true : false;
139
+      'validate' => function($value, $max) {
140
+       return $value <= $max ? true : false;
141 141
     },
142 142
       'message' => "Value must be less than {{arg_1}}.",
143 143
     ],
144 144
 
145 145
     'min' => [
146
-      'validate' => function($value,$min) {
146
+      'validate' => function($value, $min) {
147 147
          return $value >= $min;
148 148
       },
149 149
       'message' => "Value must be greater than {{arg_1}}.",
150 150
     ],
151 151
 
152 152
     'range' => [
153
-      'validate' => function($value,$min,$max) {
154
-         return ( $value >= $min ) && ( $value <= $max );
153
+      'validate' => function($value, $min, $max) {
154
+         return ($value >= $min) && ($value <= $max);
155 155
       },
156 156
       'message' => "This value must be in [{{arg_1}},{{arg_2}}] range.",
157 157
     ],
158 158
 
159 159
     'words' => [
160
-      'validate' => function($value,$max) {
160
+      'validate' => function($value, $max) {
161 161
          return str_word_count($value) <= $max;
162 162
       },
163 163
       'message' => "Too many words, max count is {{arg_1}}.",
164 164
     ],
165 165
 
166 166
     'length' => [
167
-      'validate' => function($value,$length) {
167
+      'validate' => function($value, $length) {
168 168
          return strlen($value) == $length;
169 169
       },
170 170
       'message' => "This value must be {{arg_1}} characters.",
171 171
     ],
172 172
 
173 173
     'min_length' => [
174
-      'validate' => function($value,$min) {
174
+      'validate' => function($value, $min) {
175 175
          return strlen($value) >= $min;
176 176
       },
177 177
       'message' => "Too few characters, min count is {{arg_1}}.",
178 178
     ],
179 179
 
180 180
     'max_length' => [
181
-      'validate' => function($value,$max) {
181
+      'validate' => function($value, $max) {
182 182
          return strlen($value) <= $max;
183 183
       },
184 184
       'message' => "Too many characters, max count is {{arg_1}}.",
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
     'true' => [
188 188
       'validate' => function($value) {
189
-         return (bool)$value;
189
+         return (bool) $value;
190 190
       },
191 191
       'message' => "This value must be true.",
192 192
     ],
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     ],
200 200
 
201 201
     'same_as' => [
202
-      'validate' => function($value,$fieldname) {
202
+      'validate' => function($value, $fieldname) {
203 203
        $x = isset(Check::$data[$fieldname]) ? Check::$data[$fieldname] : '';
204 204
          return $value == $x;
205 205
       },
Please login to merge, or discard this patch.
Braces   +22 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
                    $errors  = [];
18 18
   public static    $data    = [];
19 19
 
20
-  public static function valid($rules, $data){
20
+  public static function valid($rules, $data) {
21 21
     static::$errors = [];
22 22
     Event::triggerOnce('core.check.init');
23 23
     self::$data = ($data = (array)$data);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
       $current = isset($data[$field_name]) ? $data[$field_name] : null;
28 28
 
29
-      if (is_callable($rule)){
29
+      if (is_callable($rule)) {
30 30
         static::$errors[$field_name] = call_user_func($rule,$current);
31 31
         continue;
32 32
       } elseif (is_string($rule)) {
@@ -44,12 +44,14 @@  discard block
 block discarded – undo
44 44
         $opts      = $opts ? json_decode("[$opts]") : [];
45 45
         $meth_opts = $opts ? array_merge([$current], $opts) : [$current];
46 46
 
47
-        if ( static::$errors[$field_name] !== true ) continue 2;
47
+        if ( static::$errors[$field_name] !== true ) {
48
+          continue 2;
49
+        }
48 50
 
49 51
         if (empty(static::$methods[$meth_name])) {
50 52
           static::$errors[$field_name] = true;
51 53
         } else {
52
-          if (call_user_func_array(static::$methods[$meth_name]->validate,$meth_opts)){
54
+          if (call_user_func_array(static::$methods[$meth_name]->validate,$meth_opts)) {
53 55
             static::$errors[$field_name] = true;
54 56
           } else {
55 57
             $arg = [];
@@ -65,25 +67,33 @@  discard block
 block discarded – undo
65 67
     self::$data = [];
66 68
 
67 69
     // Clean non-errors
68
-    static::$errors = array_filter(static::$errors,function($v){
70
+    static::$errors = array_filter(static::$errors,function($v) {
69 71
       return $v !== true;
70 72
     });
71 73
 
72 74
     return empty(static::$errors);
73 75
   }
74 76
 
75
-  public static function method($name, $definition = null){
77
+  public static function method($name, $definition = null) {
76 78
     if (is_array($name)) {
77
-      foreach ($name as $method_name => $method_definition){
78
-        if (is_callable($method_definition)) $method_definition = ['validate' => $method_definition];
79
-        if (empty($method_definition['validate']) || !is_callable($method_definition['validate'])) continue;
79
+      foreach ($name as $method_name => $method_definition) {
80
+        if (is_callable($method_definition)) {
81
+          $method_definition = ['validate' => $method_definition];
82
+        }
83
+        if (empty($method_definition['validate']) || !is_callable($method_definition['validate'])) {
84
+          continue;
85
+        }
80 86
         $method_definition['key']      = "core.check.error.$method_name";
81 87
         $method_definition['message']  = Filter::with($method_definition['key'],@$method_definition['message']?:'Field not valid.');
82 88
         static::$methods[$method_name] = (object)$method_definition;
83 89
       }
84 90
     } else {
85
-      if (is_callable($definition)) $definition = ['validate' => $definition];
86
-      if (empty($definition['validate']) || !is_callable($definition['validate'])) return;
91
+      if (is_callable($definition)) {
92
+        $definition = ['validate' => $definition];
93
+      }
94
+      if (empty($definition['validate']) || !is_callable($definition['validate'])) {
95
+        return;
96
+      }
87 97
       $methods['key']         = "core.check.error.$name";
88 98
       $methods['message']     = Filter::with($methods['key'],@$methods['message']?:'Field not valid.');
89 99
       static::$methods[$name] = (object)$definition;
@@ -96,7 +106,7 @@  discard block
 block discarded – undo
96 106
 
97 107
 }
98 108
 
99
-Event::on('core.check.init',function(){
109
+Event::on('core.check.init',function() {
100 110
 
101 111
   Check::method([
102 112
 
Please login to merge, or discard this patch.
classes/Error.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
  */
13 13
 
14 14
 include_once __DIR__.'Errors.php';
15
-class_alias('Errors','Error',true);
15
+class_alias('Errors', 'Error', true);
Please login to merge, or discard this patch.
classes/Cache.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 class Cache {
14
-   use Module;
14
+    use Module;
15 15
    
16
-   protected static $driver = null;
17
-   protected static $enabled = true;
16
+    protected static $driver = null;
17
+    protected static $enabled = true;
18 18
 
19 19
     public static function get($key,$default='',$expire=0){
20 20
       if (static::$enabled){
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             return true;
70 70
           }
71 71
         }
72
-       return false;
72
+        return false;
73 73
     }
74 74
 
75 75
     /**
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
    protected static $driver = null;
17 17
    protected static $enabled = true;
18 18
 
19
-    public static function get($key,$default='',$expire=0){
20
-      if (static::$enabled){
19
+    public static function get($key, $default = '', $expire = 0) {
20
+      if (static::$enabled) {
21 21
         $hash = static::hash($key);
22
-        if(static::$driver->exists($hash) && $results = static::$driver->get($hash)){
22
+        if (static::$driver->exists($hash) && $results = static::$driver->get($hash)) {
23 23
             return $results;
24 24
         } else {
25
-            if($data = is_callable($default)?call_user_func($default):$default){
26
-                static::$driver->set($hash,$data,$expire);
25
+            if ($data = is_callable($default) ? call_user_func($default) : $default) {
26
+                static::$driver->set($hash, $data, $expire);
27 27
             }
28 28
             return $data;
29 29
         }
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
      *   ]);
55 55
      * 
56 56
      */
57
-    public static function using($driver){
58
-      foreach((array)$driver as $key => $value){
59
-          if(is_numeric($key)){
57
+    public static function using($driver) {
58
+      foreach ((array) $driver as $key => $value) {
59
+          if (is_numeric($key)) {
60 60
             $drv = $value;
61 61
             $conf = [];
62 62
           } else {
63 63
             $drv = $key;
64 64
             $conf = $value;
65 65
           }
66
-          $class = 'Cache\\' . ucfirst(strtolower($drv));
67
-          if(class_exists($class) && $class::valid()) {
66
+          $class = 'Cache\\'.ucfirst(strtolower($drv));
67
+          if (class_exists($class) && $class::valid()) {
68 68
             static::$driver = new $class($conf);
69 69
             return true;
70 70
           }
@@ -81,45 +81,45 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return boolean  Cache on/off status
83 83
      */
84
-    public static function enabled($enabled=null){
84
+    public static function enabled($enabled = null) {
85 85
         return $enabled ? static::$enabled : static::$enabled = $enabled;
86 86
     }
87 87
 
88 88
 
89
-    public static function set($key,$value,$expire=0){
90
-        return static::$driver->set(static::hash($key),$value,$expire);
89
+    public static function set($key, $value, $expire = 0) {
90
+        return static::$driver->set(static::hash($key), $value, $expire);
91 91
     }
92 92
 
93
-    public static function delete($key){
93
+    public static function delete($key) {
94 94
         return static::$driver->delete(static::hash($key));
95 95
     }
96 96
 
97
-    public static function exists($key){
97
+    public static function exists($key) {
98 98
         return static::$enabled && static::$driver->exists(static::hash($key));
99 99
     }
100 100
 
101
-    public static function flush(){
101
+    public static function flush() {
102 102
         return static::$driver->flush();
103 103
     }
104 104
 
105
-    public static function inc($key,$value=1){
106
-        return static::$driver->inc(static::hash($key),$value);
105
+    public static function inc($key, $value = 1) {
106
+        return static::$driver->inc(static::hash($key), $value);
107 107
     }
108 108
 
109
-    public static function dec($key,$value=1){
110
-        return static::$driver->dec(static::hash($key),$value);
109
+    public static function dec($key, $value = 1) {
110
+        return static::$driver->dec(static::hash($key), $value);
111 111
     }
112 112
 
113
-    public static function hash($key,$group=null){
113
+    public static function hash($key, $group = null) {
114 114
         static $hashes = [];
115
-        if (false === isset($hashes[$group][$key])){
115
+        if (false === isset($hashes[$group][$key])) {
116 116
             $k = $key;
117
-            if(is_array($key) && count($key)>1) list($group,$key) = $k;
118
-            $hashes[$group][$key] = ($group?$group.'-':'') . md5($key);
117
+            if (is_array($key) && count($key) > 1) list($group, $key) = $k;
118
+            $hashes[$group][$key] = ($group ? $group.'-' : '').md5($key);
119 119
         }
120 120
         return $hashes[$group][$key];
121 121
     }
122 122
 }
123 123
 
124 124
 
125
-Cache::using(['files','memory']);
125
+Cache::using(['files', 'memory']);
Please login to merge, or discard this patch.
Braces   +19 added lines, -17 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
    protected static $driver = null;
17 17
    protected static $enabled = true;
18 18
 
19
-    public static function get($key,$default='',$expire=0){
20
-      if (static::$enabled){
19
+    public static function get($key,$default='',$expire=0) {
20
+      if (static::$enabled) {
21 21
         $hash = static::hash($key);
22
-        if(static::$driver->exists($hash) && $results = static::$driver->get($hash)){
22
+        if(static::$driver->exists($hash) && $results = static::$driver->get($hash)) {
23 23
             return $results;
24 24
         } else {
25
-            if($data = is_callable($default)?call_user_func($default):$default){
25
+            if($data = is_callable($default)?call_user_func($default):$default) {
26 26
                 static::$driver->set($hash,$data,$expire);
27 27
             }
28 28
             return $data;
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
      *   ]);
55 55
      * 
56 56
      */
57
-    public static function using($driver){
58
-      foreach((array)$driver as $key => $value){
59
-          if(is_numeric($key)){
57
+    public static function using($driver) {
58
+      foreach((array)$driver as $key => $value) {
59
+          if(is_numeric($key)) {
60 60
             $drv = $value;
61 61
             $conf = [];
62 62
           } else {
@@ -81,40 +81,42 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return boolean  Cache on/off status
83 83
      */
84
-    public static function enabled($enabled=null){
84
+    public static function enabled($enabled=null) {
85 85
         return $enabled ? static::$enabled : static::$enabled = $enabled;
86 86
     }
87 87
 
88 88
 
89
-    public static function set($key,$value,$expire=0){
89
+    public static function set($key,$value,$expire=0) {
90 90
         return static::$driver->set(static::hash($key),$value,$expire);
91 91
     }
92 92
 
93
-    public static function delete($key){
93
+    public static function delete($key) {
94 94
         return static::$driver->delete(static::hash($key));
95 95
     }
96 96
 
97
-    public static function exists($key){
97
+    public static function exists($key) {
98 98
         return static::$enabled && static::$driver->exists(static::hash($key));
99 99
     }
100 100
 
101
-    public static function flush(){
101
+    public static function flush() {
102 102
         return static::$driver->flush();
103 103
     }
104 104
 
105
-    public static function inc($key,$value=1){
105
+    public static function inc($key,$value=1) {
106 106
         return static::$driver->inc(static::hash($key),$value);
107 107
     }
108 108
 
109
-    public static function dec($key,$value=1){
109
+    public static function dec($key,$value=1) {
110 110
         return static::$driver->dec(static::hash($key),$value);
111 111
     }
112 112
 
113
-    public static function hash($key,$group=null){
113
+    public static function hash($key,$group=null) {
114 114
         static $hashes = [];
115
-        if (false === isset($hashes[$group][$key])){
115
+        if (false === isset($hashes[$group][$key])) {
116 116
             $k = $key;
117
-            if(is_array($key) && count($key)>1) list($group,$key) = $k;
117
+            if(is_array($key) && count($key)>1) {
118
+              list($group,$key) = $k;
119
+            }
118 120
             $hashes[$group][$key] = ($group?$group.'-':'') . md5($key);
119 121
         }
120 122
         return $hashes[$group][$key];
Please login to merge, or discard this patch.
classes/Filter.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,30 +15,30 @@
 block discarded – undo
15 15
 
16 16
     protected static $_modders = [];
17 17
 
18
-    public static function add($name,callable $modder){
18
+    public static function add($name, callable $modder) {
19 19
         static::$_modders[$name][] = $modder;
20 20
     }
21 21
 
22
-    public static function single($name,callable $modder){
22
+    public static function single($name, callable $modder) {
23 23
         static::$_modders[$name] = [$modder];
24 24
     }
25 25
 
26
-    public static function remove($name,callable $modder = null){
27
-        if($modder === null) {
26
+    public static function remove($name, callable $modder = null) {
27
+        if ($modder === null) {
28 28
             unset(static::$_modders[$name]);
29 29
         } else {
30
-            if ($idx = array_search($modder,static::$_modders[$name],true))
30
+            if ($idx = array_search($modder, static::$_modders[$name], true))
31 31
                 unset(static::$_modders[$name][$idx]);
32 32
         }
33 33
     }
34 34
 
35
-    public static function with($names, $default){
36
-      foreach ((array)$names as $name) {
35
+    public static function with($names, $default) {
36
+      foreach ((array) $names as $name) {
37 37
         if (!empty(static::$_modders[$name])) {
38 38
             $value = $default;
39
-            $args = array_slice( func_get_args(), 2 );
39
+            $args = array_slice(func_get_args(), 2);
40 40
             foreach (static::$_modders[$name] as $modder) {
41
-                $value = call_user_func( $modder,$value,$args );
41
+                $value = call_user_func($modder, $value, $args);
42 42
             }
43 43
             return $value;
44 44
         }
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,24 +15,25 @@
 block discarded – undo
15 15
 
16 16
     protected static $_modders = [];
17 17
 
18
-    public static function add($name,callable $modder){
18
+    public static function add($name,callable $modder) {
19 19
         static::$_modders[$name][] = $modder;
20 20
     }
21 21
 
22
-    public static function single($name,callable $modder){
22
+    public static function single($name,callable $modder) {
23 23
         static::$_modders[$name] = [$modder];
24 24
     }
25 25
 
26
-    public static function remove($name,callable $modder = null){
26
+    public static function remove($name,callable $modder = null) {
27 27
         if($modder === null) {
28 28
             unset(static::$_modders[$name]);
29 29
         } else {
30
-            if ($idx = array_search($modder,static::$_modders[$name],true))
31
-                unset(static::$_modders[$name][$idx]);
30
+            if ($idx = array_search($modder,static::$_modders[$name],true)) {
31
+                            unset(static::$_modders[$name][$idx]);
32
+            }
32 33
         }
33 34
     }
34 35
 
35
-    public static function with($names, $default){
36
+    public static function with($names, $default) {
36 37
       foreach ((array)$names as $name) {
37 38
         if (!empty(static::$_modders[$name])) {
38 39
             $value = $default;
Please login to merge, or discard this patch.
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/Proxy.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@
 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){
24
-    \Event::trigger('core.email.send',$envelope->to(),$envelope,'proxy');
23
+  public function onSend(Envelope $envelope) {
24
+    \Event::trigger('core.email.send', $envelope->to(), $envelope, 'proxy');
25 25
     \Event::trigger($this->listener, $envelope);
26 26
     return true;
27 27
   }
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,11 +16,13 @@
 block discarded – undo
16 16
 
17 17
   protected $listener = 'core.email.proxy.send';
18 18
 
19
-  public function onInit($options){
20
-    if (!empty($options['hook'])) $this->listener = $options['hook'];
19
+  public function onInit($options) {
20
+    if (!empty($options['hook'])) {
21
+      $this->listener = $options['hook'];
22
+    }
21 23
   }
22 24
 
23
-  public function onSend(Envelope $envelope){
25
+  public function onSend(Envelope $envelope) {
24 26
     \Event::trigger('core.email.send',$envelope->to(),$envelope,'proxy');
25 27
     \Event::trigger($this->listener, $envelope);
26 28
     return true;
Please login to merge, or discard this patch.