Completed
Push — master ( bb34f0...023ff5 )
by Stefano
03:08
created
classes/Email.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@
 block discarded – undo
14 14
   use Module;
15 15
 
16 16
   protected static $driver,
17
-                   $options,
18
-                   $driver_name;
17
+                    $options,
18
+                    $driver_name;
19 19
 
20 20
   public static function using($driver, $options = null){
21 21
     $class = 'Email\\'.ucfirst(strtolower($driver));
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,17 +17,19 @@  discard block
 block discarded – undo
17 17
                    $options,
18 18
                    $driver_name;
19 19
 
20
-  public static function using($driver, $options = null){
20
+  public static function using($driver, $options = null) {
21 21
     $class = 'Email\\'.ucfirst(strtolower($driver));
22
-    if ( ! class_exists($class) ) throw new Exception("[core.email] : $driver driver not found.");
22
+    if ( ! class_exists($class) ) {
23
+      throw new Exception("[core.email] : $driver driver not found.");
24
+    }
23 25
     static::$driver_name = $driver;
24 26
     static::$options     = $options;
25 27
     static::$driver      = new $class;
26 28
     static::$driver->onInit($options);
27 29
   }
28 30
 
29
-  public static function create($mail=[]){
30
-    if (is_a($mail, 'Email\\Envelope')){
31
+  public static function create($mail=[]) {
32
+    if (is_a($mail, 'Email\\Envelope')) {
31 33
       return $mail;
32 34
     } else {
33 35
       return new Email\Envelope(array_merge([
@@ -43,7 +45,7 @@  discard block
 block discarded – undo
43 45
     }
44 46
   }
45 47
 
46
-  public static function send($mail){
48
+  public static function send($mail) {
47 49
     return static::$driver->onSend(static::create($mail));
48 50
   }
49 51
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
                    $options,
18 18
                    $driver_name;
19 19
 
20
-  public static function using($driver, $options = null){
20
+  public static function using($driver, $options = null) {
21 21
     $class = 'Email\\'.ucfirst(strtolower($driver));
22
-    if ( ! class_exists($class) ) throw new Exception("[core.email] : $driver driver not found.");
22
+    if (!class_exists($class)) throw new Exception("[core.email] : $driver driver not found.");
23 23
     static::$driver_name = $driver;
24 24
     static::$options     = $options;
25 25
     static::$driver      = new $class;
26 26
     static::$driver->onInit($options);
27 27
   }
28 28
 
29
-  public static function create($mail=[]){
30
-    if (is_a($mail, 'Email\\Envelope')){
29
+  public static function create($mail = []) {
30
+    if (is_a($mail, 'Email\\Envelope')) {
31 31
       return $mail;
32 32
     } else {
33 33
       return new Email\Envelope(array_merge([
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
     }
44 44
   }
45 45
 
46
-  public static function send($mail){
46
+  public static function send($mail) {
47 47
     $envelope = static::create($mail);
48 48
     $results = (array) static::$driver->onSend($envelope);
49 49
     Event::trigger('core.email.send', $envelope->to(), $envelope, static::$driver, $results);
50
-    return count($results) && array_reduce( $results, function($carry, $item) {
50
+    return count($results) && array_reduce($results, function($carry, $item) {
51 51
       return $carry && $item;
52
-    }, true );
52
+    }, true);
53 53
   }
54 54
 
55 55
 }
Please login to merge, or discard this patch.
classes/Module.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 trait Module {
14 14
     static protected $__classMethods = array();
15 15
     
16
-    public function __call($name, $args){
16
+    public function __call($name, $args) {
17 17
         if (isset(static::$__classMethods[$name]) && static::$__classMethods[$name] instanceof \Closure) {
18 18
             return call_user_func_array(static::$__classMethods[$name]->bindTo($this, $this), $args);
19 19
         }
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
         throw new \BadMethodCallException;
26 26
     }
27 27
     
28
-    public static function __prototypeAdd($name, \Closure $method){
28
+    public static function __prototypeAdd($name, \Closure $method) {
29 29
         static::$__classMethods[$name] = $method;
30 30
     }
31 31
 
32
-    public static function __prototypeGet($name){
33
-        return isset(static::$__classMethods[$name])?static::$__classMethods[$name]:null;
32
+    public static function __prototypeGet($name) {
33
+        return isset(static::$__classMethods[$name]) ? static::$__classMethods[$name] : null;
34 34
     }
35 35
     
36
-    public static function __prototypeRemove($name){
36
+    public static function __prototypeRemove($name) {
37 37
         unset(static::$__classMethods[$name]);
38 38
     }
39 39
     
40
-    public static function __callStatic($name, $args){
40
+    public static function __callStatic($name, $args) {
41 41
         if (isset(static::$__classMethods[$name]) && static::$__classMethods[$name] instanceof \Closure) {
42 42
             return forward_static_call_array(static::$__classMethods[$name], $args);
43 43
         }
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
         throw new \BadMethodCallException;
50 50
     }
51 51
     
52
-    public static function extend($methodMap=[]){
52
+    public static function extend($methodMap = []) {
53 53
         if ($methodMap) foreach ($methodMap as $name => $method) {
54
-            if($method && $method instanceof \Closure) {
55
-                static::__prototypeAdd($name,$method);
54
+            if ($method && $method instanceof \Closure) {
55
+                static::__prototypeAdd($name, $method);
56 56
             } else throw new \BadMethodCallException;
57 57
         }
58 58
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 trait Module {
14 14
     static protected $__classMethods = array();
15 15
     
16
-    public function __call($name, $args){
16
+    public function __call($name, $args) {
17 17
         if (isset(static::$__classMethods[$name]) && static::$__classMethods[$name] instanceof \Closure) {
18 18
             return call_user_func_array(static::$__classMethods[$name]->bindTo($this, $this), $args);
19 19
         }
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
         throw new \BadMethodCallException;
26 26
     }
27 27
     
28
-    public static function __prototypeAdd($name, \Closure $method){
28
+    public static function __prototypeAdd($name, \Closure $method) {
29 29
         static::$__classMethods[$name] = $method;
30 30
     }
31 31
 
32
-    public static function __prototypeGet($name){
32
+    public static function __prototypeGet($name) {
33 33
         return isset(static::$__classMethods[$name])?static::$__classMethods[$name]:null;
34 34
     }
35 35
     
36
-    public static function __prototypeRemove($name){
36
+    public static function __prototypeRemove($name) {
37 37
         unset(static::$__classMethods[$name]);
38 38
     }
39 39
     
40
-    public static function __callStatic($name, $args){
40
+    public static function __callStatic($name, $args) {
41 41
         if (isset(static::$__classMethods[$name]) && static::$__classMethods[$name] instanceof \Closure) {
42 42
             return forward_static_call_array(static::$__classMethods[$name], $args);
43 43
         }
@@ -49,11 +49,15 @@  discard block
 block discarded – undo
49 49
         throw new \BadMethodCallException;
50 50
     }
51 51
     
52
-    public static function extend($methodMap=[]){
53
-        if ($methodMap) foreach ($methodMap as $name => $method) {
52
+    public static function extend($methodMap=[]) {
53
+        if ($methodMap) {
54
+          foreach ($methodMap as $name => $method) {
54 55
             if($method && $method instanceof \Closure) {
55 56
                 static::__prototypeAdd($name,$method);
56
-            } else throw new \BadMethodCallException;
57
+        }
58
+            } else {
59
+              throw new \BadMethodCallException;
60
+            }
57 61
         }
58 62
     }
59 63
 }
Please login to merge, or discard this patch.
classes/Work.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
   }
35 35
 
36 36
   public static function send($id,$passValue) {
37
-     isset(self::$workers[$id]) && self::$workers[$id]->pass($passValue);
37
+      isset(self::$workers[$id]) && self::$workers[$id]->pass($passValue);
38 38
   }
39 39
 
40 40
   public static function run(){
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
       $task = self::$pool->dequeue();
44 44
       $task->run();
45 45
       if ($task->complete()) {
46
-         unset(self::$workers[$task->id()]);
46
+          unset(self::$workers[$task->id()]);
47 47
       } else {
48 48
           self::$pool->enqueue($task);
49 49
       }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
   protected static $workers;
22 22
   protected static $lastID = 0;
23 23
 
24
-  public static function add($id, $job=null){
25
-    self::$pool or ( self::$pool = new \SplQueue() );
26
-    if(is_callable($id) && $job===null){
24
+  public static function add($id, $job = null) {
25
+    self::$pool or (self::$pool = new \SplQueue());
26
+    if (is_callable($id) && $job === null) {
27 27
       $job = $id;
28 28
       $id = ++self::$lastID;
29 29
     }
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
     return $task;
34 34
   }
35 35
 
36
-  public static function send($id,$passValue) {
36
+  public static function send($id, $passValue) {
37 37
      isset(self::$workers[$id]) && self::$workers[$id]->pass($passValue);
38 38
   }
39 39
 
40
-  public static function run(){
41
-    self::$pool or ( self::$pool = new \SplQueue() );
40
+  public static function run() {
41
+    self::$pool or (self::$pool = new \SplQueue());
42 42
     while (!self::$pool->isEmpty()) {
43 43
       $task = self::$pool->dequeue();
44 44
       $task->run();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * Defer callback execution after script execution
55 55
    * @param callable $callback The deferred callback
56 56
    */ d
57
-  public static function after(callable $callback){
57
+  public static function after(callable $callback) {
58 58
     static::$inited_shutdown || static::install_shutdown();
59 59
     Event::on('core.shutdown', $callback);
60 60
   }
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
   /**
63 63
    * Single shot defer handeler install
64 64
    */
65
-  protected static function install_shutdown(){
65
+  protected static function install_shutdown() {
66 66
     if (static::$inited_shutdown) return;
67 67
     
68 68
     // Disable time limit
69 69
     set_time_limit(0);
70 70
     
71 71
     // HHVM support
72
-    if(function_exists('register_postsend_function')){
73
-      register_postsend_function(function(){
72
+    if (function_exists('register_postsend_function')) {
73
+      register_postsend_function(function() {
74 74
         Event::trigger('core.shutdown');
75 75
       });
76
-    } else if(function_exists('fastcgi_finish_request')) {
77
-      register_shutdown_function(function(){
76
+    } else if (function_exists('fastcgi_finish_request')) {
77
+      register_shutdown_function(function() {
78 78
         fastcgi_finish_request();
79 79
         Event::trigger('core.shutdown');
80 80
       });       
81 81
     } else {
82
-      register_shutdown_function(function(){
82
+      register_shutdown_function(function() {
83 83
         Event::trigger('core.shutdown');
84 84
       });
85 85
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     }
122 122
 
123 123
     public function complete() {
124
-        return ! $this->coroutine->valid();
124
+        return !$this->coroutine->valid();
125 125
     }
126 126
 
127 127
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
   protected static $workers;
22 22
   protected static $lastID = 0;
23 23
 
24
-  public static function add($id, $job=null){
24
+  public static function add($id, $job=null) {
25 25
     self::$pool or ( self::$pool = new \SplQueue() );
26
-    if(is_callable($id) && $job===null){
26
+    if(is_callable($id) && $job===null) {
27 27
       $job = $id;
28 28
       $id = ++self::$lastID;
29 29
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      isset(self::$workers[$id]) && self::$workers[$id]->pass($passValue);
38 38
   }
39 39
 
40
-  public static function run(){
40
+  public static function run() {
41 41
     self::$pool or ( self::$pool = new \SplQueue() );
42 42
     while (!self::$pool->isEmpty()) {
43 43
       $task = self::$pool->dequeue();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * Defer callback execution after script execution
55 55
    * @param callable $callback The deferred callback
56 56
    */ d
57
-  public static function after(callable $callback){
57
+  public static function after(callable $callback) {
58 58
     static::$inited_shutdown || static::install_shutdown();
59 59
     Event::on('core.shutdown', $callback);
60 60
   }
@@ -62,24 +62,26 @@  discard block
 block discarded – undo
62 62
   /**
63 63
    * Single shot defer handeler install
64 64
    */
65
-  protected static function install_shutdown(){
66
-    if (static::$inited_shutdown) return;
65
+  protected static function install_shutdown() {
66
+    if (static::$inited_shutdown) {
67
+      return;
68
+    }
67 69
     
68 70
     // Disable time limit
69 71
     set_time_limit(0);
70 72
     
71 73
     // HHVM support
72
-    if(function_exists('register_postsend_function')){
73
-      register_postsend_function(function(){
74
+    if(function_exists('register_postsend_function')) {
75
+      register_postsend_function(function() {
74 76
         Event::trigger('core.shutdown');
75 77
       });
76 78
     } else if(function_exists('fastcgi_finish_request')) {
77
-      register_shutdown_function(function(){
79
+      register_shutdown_function(function() {
78 80
         fastcgi_finish_request();
79 81
         Event::trigger('core.shutdown');
80 82
       });       
81 83
     } else {
82
-      register_shutdown_function(function(){
84
+      register_shutdown_function(function() {
83 85
         Event::trigger('core.shutdown');
84 86
       });
85 87
     }
Please login to merge, or discard this patch.
classes/Cache/Files.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@  discard block
 block discarded – undo
15 15
 class Files implements Adapter {
16 16
     protected $options;
17 17
 
18
-    public static function valid(){
18
+    public static function valid() {
19 19
         return true;
20 20
     }
21 21
 
22
-    public function __construct($options=[]){
23
-        $this->options = (object) array_merge($options,[
22
+    public function __construct($options = []) {
23
+        $this->options = (object) array_merge($options, [
24 24
             'cache_dir' => sys_get_temp_dir().'/core_file_cache',
25 25
         ]);
26
-        $this->options->cache_dir = rtrim($this->options->cache_dir,'/');
27
-        if(false===is_dir($this->options->cache_dir)) mkdir($this->options->cache_dir,0777,true);
26
+        $this->options->cache_dir = rtrim($this->options->cache_dir, '/');
27
+        if (false === is_dir($this->options->cache_dir)) mkdir($this->options->cache_dir, 0777, true);
28 28
         $this->options->cache_dir .= '/';
29 29
     }
30 30
 
31
-    public function get($key){
31
+    public function get($key) {
32 32
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
33
-        if(is_file($cache_file_name) && $data = @unserialize(file_get_contents($cache_file_name))){
34
-            if($data[0] && (time() > $data[0])) {
33
+        if (is_file($cache_file_name) && $data = @unserialize(file_get_contents($cache_file_name))) {
34
+            if ($data[0] && (time() > $data[0])) {
35 35
                 unlink($cache_file_name);
36 36
                 return null;
37 37
             }
@@ -41,39 +41,39 @@  discard block
 block discarded – undo
41 41
         }
42 42
     }
43 43
 
44
-    public function set($key,$value,$expire=0){
44
+    public function set($key, $value, $expire = 0) {
45 45
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
46
-        file_put_contents($cache_file_name,serialize([$expire?time()+$expire:0,$value]));
46
+        file_put_contents($cache_file_name, serialize([$expire ? time() + $expire : 0, $value]));
47 47
     }
48 48
 
49
-    public function delete($key){
49
+    public function delete($key) {
50 50
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
51
-      if(is_file($cache_file_name)) unlink($cache_file_name);
51
+      if (is_file($cache_file_name)) unlink($cache_file_name);
52 52
     }
53 53
 
54
-    public function exists($key){
54
+    public function exists($key) {
55 55
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
56
-        if(false === is_file($cache_file_name)) return false;
57
-        $peek = file_get_contents($cache_file_name,false,null,-1,32);
58
-        $expire = explode('{i:0;i:',$peek,2);
59
-        $expire = explode(';',end($expire),2);
56
+        if (false === is_file($cache_file_name)) return false;
57
+        $peek = file_get_contents($cache_file_name, false, null, -1, 32);
58
+        $expire = explode('{i:0;i:', $peek, 2);
59
+        $expire = explode(';', end($expire), 2);
60 60
         $expire = current($expire);
61
-        if($expire && $expire < time()){
61
+        if ($expire && $expire < time()) {
62 62
             unlink($cache_file_name);
63 63
             return false;
64 64
         } else return true;
65 65
     }
66 66
 
67
-    public function flush(){
68
-        exec('rm -f ' . $this->options->cache_dir . '*.cache.php');
67
+    public function flush() {
68
+        exec('rm -f '.$this->options->cache_dir.'*.cache.php');
69 69
     }
70 70
 
71
-    public function inc($key,$value=1){
72
-        if(null === ($current = $this->get($key))) $current = $value; else $current += $value;
73
-        $this->set($key,$current);
71
+    public function inc($key, $value = 1) {
72
+        if (null === ($current = $this->get($key))) $current = $value;else $current += $value;
73
+        $this->set($key, $current);
74 74
     }
75 75
 
76
-    public function dec($key,$value=1){
77
-        $this->inc($key,-abs($value));
76
+    public function dec($key, $value = 1) {
77
+        $this->inc($key, -abs($value));
78 78
     }
79 79
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,22 +15,24 @@  discard block
 block discarded – undo
15 15
 class Files implements Adapter {
16 16
     protected $options;
17 17
 
18
-    public static function valid(){
18
+    public static function valid() {
19 19
         return true;
20 20
     }
21 21
 
22
-    public function __construct($options=[]){
22
+    public function __construct($options=[]) {
23 23
         $this->options = (object) array_merge($options,[
24 24
             'cache_dir' => sys_get_temp_dir().'/core_file_cache',
25 25
         ]);
26 26
         $this->options->cache_dir = rtrim($this->options->cache_dir,'/');
27
-        if(false===is_dir($this->options->cache_dir)) mkdir($this->options->cache_dir,0777,true);
27
+        if(false===is_dir($this->options->cache_dir)) {
28
+          mkdir($this->options->cache_dir,0777,true);
29
+        }
28 30
         $this->options->cache_dir .= '/';
29 31
     }
30 32
 
31
-    public function get($key){
33
+    public function get($key) {
32 34
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
33
-        if(is_file($cache_file_name) && $data = @unserialize(file_get_contents($cache_file_name))){
35
+        if(is_file($cache_file_name) && $data = @unserialize(file_get_contents($cache_file_name))) {
34 36
             if($data[0] && (time() > $data[0])) {
35 37
                 unlink($cache_file_name);
36 38
                 return null;
@@ -41,39 +43,49 @@  discard block
 block discarded – undo
41 43
         }
42 44
     }
43 45
 
44
-    public function set($key,$value,$expire=0){
46
+    public function set($key,$value,$expire=0) {
45 47
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
46 48
         file_put_contents($cache_file_name,serialize([$expire?time()+$expire:0,$value]));
47 49
     }
48 50
 
49
-    public function delete($key){
51
+    public function delete($key) {
50 52
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
51
-      if(is_file($cache_file_name)) unlink($cache_file_name);
53
+      if(is_file($cache_file_name)) {
54
+        unlink($cache_file_name);
55
+      }
52 56
     }
53 57
 
54
-    public function exists($key){
58
+    public function exists($key) {
55 59
         $cache_file_name = $this->options->cache_dir.$key.'.cache.php';
56
-        if(false === is_file($cache_file_name)) return false;
60
+        if(false === is_file($cache_file_name)) {
61
+          return false;
62
+        }
57 63
         $peek = file_get_contents($cache_file_name,false,null,-1,32);
58 64
         $expire = explode('{i:0;i:',$peek,2);
59 65
         $expire = explode(';',end($expire),2);
60 66
         $expire = current($expire);
61
-        if($expire && $expire < time()){
67
+        if($expire && $expire < time()) {
62 68
             unlink($cache_file_name);
63 69
             return false;
64
-        } else return true;
70
+        } else {
71
+          return true;
72
+        }
65 73
     }
66 74
 
67
-    public function flush(){
75
+    public function flush() {
68 76
         exec('rm -f ' . $this->options->cache_dir . '*.cache.php');
69 77
     }
70 78
 
71
-    public function inc($key,$value=1){
72
-        if(null === ($current = $this->get($key))) $current = $value; else $current += $value;
79
+    public function inc($key,$value=1) {
80
+        if(null === ($current = $this->get($key))) {
81
+          $current = $value;
82
+        } else {
83
+          $current += $value;
84
+        }
73 85
         $this->set($key,$current);
74 86
     }
75 87
 
76
-    public function dec($key,$value=1){
88
+    public function dec($key,$value=1) {
77 89
         $this->inc($key,-abs($value));
78 90
     }
79 91
 }
Please login to merge, or discard this patch.
classes/Cache/Adapter.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
 
13 13
 namespace Cache;
14 14
 
15
-interface Adapter  {
15
+interface Adapter {
16 16
   public function get($key);
17
-  public function set($key,$value,$expire=0);
17
+  public function set($key, $value, $expire = 0);
18 18
   public function delete($key);
19 19
   public function exists($key);
20 20
   public function flush();
21 21
 
22
-  public function inc($key,$value=1);
23
-  public function dec($key,$value=1);
22
+  public function inc($key, $value = 1);
23
+  public function dec($key, $value = 1);
24 24
 
25 25
   public static function valid();
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace Cache;
14 14
 
15
-interface Adapter  {
15
+interface Adapter {
16 16
   public function get($key);
17 17
   public function set($key,$value,$expire=0);
18 18
   public function delete($key);
Please login to merge, or discard this patch.
classes/Cache/Memory.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 
17 17
   protected $memory = [];
18 18
 
19
-    public static function valid(){
19
+    public static function valid() {
20 20
         return true;
21 21
     }
22 22
 
23
-    public function get($key){
24
-      if(isset($this->memory[$key])){
25
-        if($this->memory[$key][1] && (time() > $this->memory[$key][1])) {
23
+    public function get($key) {
24
+      if (isset($this->memory[$key])) {
25
+        if ($this->memory[$key][1] && (time() > $this->memory[$key][1])) {
26 26
           unset($this->memory[$key]);
27 27
           return null;
28 28
         }
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
       }
31 31
     }
32 32
 
33
-    public function set($key,$value,$expire=0){
34
-      $this->memory[$key] = [$value,$expire?time()+$expire:0];
33
+    public function set($key, $value, $expire = 0) {
34
+      $this->memory[$key] = [$value, $expire ? time() + $expire : 0];
35 35
     }
36 36
 
37
-    public function delete($key){
37
+    public function delete($key) {
38 38
       unset($this->memory[$key]);
39 39
     }
40 40
 
41
-    public function exists($key){
41
+    public function exists($key) {
42 42
       return isset($this->memory[$key]) && (!$this->memory[$key][1] || (time() <= $this->memory[$key][1]));
43 43
     }
44 44
 
45
-    public function flush(){
45
+    public function flush() {
46 46
       $this->memory = [];
47 47
     }
48 48
 
49
-    public function inc($key,$value=1){
49
+    public function inc($key, $value = 1) {
50 50
       return isset($this->memory[$key]) ? $this->memory[$key][0] += $value : $this->memory[$key][0] = $value;
51 51
     }
52 52
 
53
-    public function dec($key,$value=1){
54
-        $this->inc($key,-abs($value));
53
+    public function dec($key, $value = 1) {
54
+        $this->inc($key, -abs($value));
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
 
17 17
   protected $memory = [];
18 18
 
19
-    public static function valid(){
19
+    public static function valid() {
20 20
         return true;
21 21
     }
22 22
 
23
-    public function get($key){
24
-      if(isset($this->memory[$key])){
23
+    public function get($key) {
24
+      if(isset($this->memory[$key])) {
25 25
         if($this->memory[$key][1] && (time() > $this->memory[$key][1])) {
26 26
           unset($this->memory[$key]);
27 27
           return null;
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
       }
31 31
     }
32 32
 
33
-    public function set($key,$value,$expire=0){
33
+    public function set($key,$value,$expire=0) {
34 34
       $this->memory[$key] = [$value,$expire?time()+$expire:0];
35 35
     }
36 36
 
37
-    public function delete($key){
37
+    public function delete($key) {
38 38
       unset($this->memory[$key]);
39 39
     }
40 40
 
41
-    public function exists($key){
41
+    public function exists($key) {
42 42
       return isset($this->memory[$key]) && (!$this->memory[$key][1] || (time() <= $this->memory[$key][1]));
43 43
     }
44 44
 
45
-    public function flush(){
45
+    public function flush() {
46 46
       $this->memory = [];
47 47
     }
48 48
 
49
-    public function inc($key,$value=1){
49
+    public function inc($key,$value=1) {
50 50
       return isset($this->memory[$key]) ? $this->memory[$key][0] += $value : $this->memory[$key][0] = $value;
51 51
     }
52 52
 
53
-    public function dec($key,$value=1){
53
+    public function dec($key,$value=1) {
54 54
         $this->inc($key,-abs($value));
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
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.