Completed
Push — master ( e0623f...313c90 )
by Flavio
02:57
created
classes/File.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@
 block discarded – undo
22 22
     }
23 23
 
24 24
     public static function unmount($alias) {
25
-       unset(static::$mount_points[$alias]);
25
+        unset(static::$mount_points[$alias]);
26 26
     }
27 27
 
28 28
     public static function mounts() {
29
-       return array_keys(static::$mount_points);
29
+        return array_keys(static::$mount_points);
30 30
     }
31 31
 
32 32
     public static function __callStatic($name, $params) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
 
32 32
     public static function __callStatic($name, $params) {
33 33
         $uri = array_shift($params);
34
-        if ($file_location = static::locate($uri)){
34
+        if ($file_location = static::locate($uri)) {
35 35
             list($mount, $path) = $file_location;
36 36
             array_unshift($params, static::resolvePath($path));
37 37
             if (empty(static::$mount_points[$mount])) return false;
38
-            return call_user_func_array([static::$mount_points[$mount],$name],$params);
38
+            return call_user_func_array([static::$mount_points[$mount], $name], $params);
39 39
         } else return false;
40 40
     }
41 41
 
42 42
     public static function locate($path) {
43
-        if (strpos($path,'://')!==false) {
44
-            list($mount, $filepath) = explode('://',$path,2);
43
+        if (strpos($path, '://') !== false) {
44
+            list($mount, $filepath) = explode('://', $path, 2);
45 45
             $filepath = static::resolvePath($filepath);
46 46
             return isset(static::$mount_points[$mount]) ? [$mount, $filepath] : false;
47 47
         } else {
48 48
             $path = static::resolvePath($path);
49
-            foreach(static::$mount_points as $mount => $fs){
49
+            foreach (static::$mount_points as $mount => $fs) {
50 50
                 if ($fs->exists($path)) return [$mount, $path];
51 51
             }
52 52
             return false;
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
                 $absolutes[] = $part;
66 66
             }
67 67
         }
68
-        return trim(implode('/', $absolutes),'/');
68
+        return trim(implode('/', $absolutes), '/');
69 69
     }
70 70
 
71
-    public static function search($pattern, $recursive=true){
71
+    public static function search($pattern, $recursive = true) {
72 72
         $results = [];
73 73
         foreach (static::$mount_points as $mount => $fs) {
74
-            foreach($fs->search($pattern, $recursive) as $path) {
74
+            foreach ($fs->search($pattern, $recursive) as $path) {
75 75
                 $results[] = $mount.'://'.$path;
76 76
             }
77 77
         }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     }
80 80
 
81 81
 
82
-    public static function move($old,$new) {
82
+    public static function move($old, $new) {
83 83
         $src  = static::locate($old);
84 84
         $dest = static::locate($new);
85 85
         if ($src && $dest) {
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
             $_dfs = static::$mount_points[$dest[0]];
88 88
             if ($src[0] == $dest[0]) {
89 89
                 // Same filesystem
90
-                return $_sfs->move($src[1],$dest[1]);
90
+                return $_sfs->move($src[1], $dest[1]);
91 91
             } else {
92
-                return $_dfs->write($dest[1],$_sfs->read($src[1])) && $_sfs->delete($src[1]);
92
+                return $_dfs->write($dest[1], $_sfs->read($src[1])) && $_sfs->delete($src[1]);
93 93
             }
94 94
         } else return false;
95 95
     }
Please login to merge, or discard this patch.
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
     public static function mount($alias, $driver, $options = null) {
19 19
         $driver_class = '\\FileSystem\\'.ucfirst(strtolower($driver));
20
-        if (!class_exists($driver_class)) throw new \Exception('Filesystem adapter '.$driver.' not found.');
20
+        if (!class_exists($driver_class)) {
21
+          throw new \Exception('Filesystem adapter '.$driver.' not found.');
22
+        }
21 23
         static::$mount_points[$alias] = new $driver_class($options);
22 24
     }
23 25
 
@@ -31,12 +33,16 @@  discard block
 block discarded – undo
31 33
 
32 34
     public static function __callStatic($name, $params) {
33 35
         $uri = array_shift($params);
34
-        if ($file_location = static::locate($uri)){
36
+        if ($file_location = static::locate($uri)) {
35 37
             list($mount, $path) = $file_location;
36 38
             array_unshift($params, static::resolvePath($path));
37
-            if (empty(static::$mount_points[$mount])) return false;
39
+            if (empty(static::$mount_points[$mount])) {
40
+              return false;
41
+            }
38 42
             return call_user_func_array([static::$mount_points[$mount],$name],$params);
39
-        } else return false;
43
+        } else {
44
+          return false;
45
+        }
40 46
     }
41 47
 
42 48
     public static function locate($path) {
@@ -46,8 +52,10 @@  discard block
 block discarded – undo
46 52
             return isset(static::$mount_points[$mount]) ? [$mount, $filepath] : false;
47 53
         } else {
48 54
             $path = static::resolvePath($path);
49
-            foreach(static::$mount_points as $mount => $fs){
50
-                if ($fs->exists($path)) return [$mount, $path];
55
+            foreach(static::$mount_points as $mount => $fs) {
56
+                if ($fs->exists($path)) {
57
+                  return [$mount, $path];
58
+                }
51 59
             }
52 60
             return false;
53 61
         }
@@ -58,7 +66,9 @@  discard block
 block discarded – undo
58 66
         $parts = array_filter(explode('/', $path), 'strlen');
59 67
         $absolutes = [];
60 68
         foreach ($parts as $part) {
61
-            if ('.' == $part) continue;
69
+            if ('.' == $part) {
70
+              continue;
71
+            }
62 72
             if ('..' == $part) {
63 73
                 array_pop($absolutes);
64 74
             } else {
@@ -68,7 +78,7 @@  discard block
 block discarded – undo
68 78
         return trim(implode('/', $absolutes),'/');
69 79
     }
70 80
 
71
-    public static function search($pattern, $recursive=true){
81
+    public static function search($pattern, $recursive=true) {
72 82
         $results = [];
73 83
         foreach (static::$mount_points as $mount => $fs) {
74 84
             foreach($fs->search($pattern, $recursive) as $path) {
@@ -91,7 +101,9 @@  discard block
 block discarded – undo
91 101
             } else {
92 102
                 return $_dfs->write($dest[1],$_sfs->read($src[1])) && $_sfs->delete($src[1]);
93 103
             }
94
-        } else return false;
104
+        } else {
105
+          return false;
106
+        }
95 107
     }
96 108
 
97 109
 
Please login to merge, or discard this patch.
classes/Service.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@
 block discarded – undo
28 28
     }
29 29
 
30 30
     public static function __callStatic($serviceName, $serviceParameters){
31
-    	return empty(static::$services[$serviceName])
31
+      return empty(static::$services[$serviceName])
32 32
                    ? null
33 33
                    : (is_callable(static::$services[$serviceName])
34 34
                        ? call_user_func_array( static::$services[$serviceName], $serviceParameters)
35 35
                        : static::$services[$serviceName]
36
-                   );
36
+                    );
37 37
     }
38 38
 
39 39
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@
 block discarded – undo
15 15
     use Module;
16 16
     private static $services = [];
17 17
 
18
-    public static function register($serviceName, $serviceFactory){
18
+    public static function register($serviceName, $serviceFactory) {
19 19
       static::$services[$serviceName] = function() use ($serviceName, $serviceFactory) {
20 20
         return static::$services[$serviceName] = call_user_func_array($serviceFactory, func_get_args());
21 21
       };
22 22
     }
23 23
 
24
-    public static function registerFactory($serviceName, $serviceFactory){
24
+    public static function registerFactory($serviceName, $serviceFactory) {
25 25
         static::$services[$serviceName] = function() use ($serviceName, $serviceFactory) {
26 26
             return call_user_func_array($serviceFactory, func_get_args());
27 27
         };
28 28
     }
29 29
 
30
-    public static function __callStatic($serviceName, $serviceParameters){
30
+    public static function __callStatic($serviceName, $serviceParameters) {
31 31
     	return empty(static::$services[$serviceName])
32 32
                    ? null
33 33
                    : (is_callable(static::$services[$serviceName])
34
-                       ? call_user_func_array( static::$services[$serviceName], $serviceParameters)
34
+                       ? call_user_func_array(static::$services[$serviceName], $serviceParameters)
35 35
                        : static::$services[$serviceName]
36 36
                    );
37 37
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@
 block discarded – undo
15 15
     use Module;
16 16
     private static $services = [];
17 17
 
18
-    public static function register($serviceName, $serviceFactory){
18
+    public static function register($serviceName, $serviceFactory) {
19 19
       static::$services[$serviceName] = function() use ($serviceName, $serviceFactory) {
20 20
         return static::$services[$serviceName] = call_user_func_array($serviceFactory, func_get_args());
21 21
       };
22 22
     }
23 23
 
24
-    public static function registerFactory($serviceName, $serviceFactory){
24
+    public static function registerFactory($serviceName, $serviceFactory) {
25 25
         static::$services[$serviceName] = function() use ($serviceName, $serviceFactory) {
26 26
             return call_user_func_array($serviceFactory, func_get_args());
27 27
         };
28 28
     }
29 29
 
30
-    public static function __callStatic($serviceName, $serviceParameters){
30
+    public static function __callStatic($serviceName, $serviceParameters) {
31 31
     	return empty(static::$services[$serviceName])
32 32
                    ? null
33 33
                    : (is_callable(static::$services[$serviceName])
Please login to merge, or discard this patch.
classes/Shell.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
                   $w[] = '--'.$value;                      
33 33
                 } else {
34 34
                   if(is_bool($value)){
35
-                     if($value) $w[] = '--'.$key;
35
+                      if($value) $w[] = '--'.$key;
36 36
                   } else { 
37 37
                     $w[] = '--'.$key.'='.escapeshellarg($value);  
38 38
                   }                    
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
      * @param array $params 
23 23
      * @return string
24 24
      */
25
-    protected static function _compileCommand($command,array $params){
25
+    protected static function _compileCommand($command, array $params) {
26 26
         $s = $w = [];
27 27
         foreach ($params as $p) {
28 28
             if ($p instanceof static) {
29 29
               $s[] = '$('.$p->getShellCommand().')';
30 30
             } else if (is_array($p)) foreach ($p as $key => $value) {
31
-                if(is_numeric($key)){
31
+                if (is_numeric($key)) {
32 32
                   $w[] = '--'.$value;                      
33 33
                 } else {
34
-                  if(is_bool($value)){
35
-                     if($value) $w[] = '--'.$key;
34
+                  if (is_bool($value)) {
35
+                     if ($value) $w[] = '--'.$key;
36 36
                   } else { 
37 37
                     $w[] = '--'.$key.'='.escapeshellarg($value);  
38 38
                   }                    
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             }
43 43
         }
44 44
         return trim(
45
-            '/usr/bin/env '.$command.' '.implode(' ',array_merge($w,$s))
45
+            '/usr/bin/env '.$command.' '.implode(' ', array_merge($w, $s))
46 46
         );
47 47
     }
48 48
  
@@ -50,68 +50,68 @@  discard block
 block discarded – undo
50 50
      * Returns the compiled shell command
51 51
      * @return string
52 52
      */
53
-    public function getShellCommand(){
53
+    public function getShellCommand() {
54 54
         return $this->command;
55 55
     }
56 56
 
57
-    public static function __callStatic($command,$params){
57
+    public static function __callStatic($command, $params) {
58 58
         // Check if is an alias
59
-        if (isset(static::$aliases[$command])){
60
-            if(!$results = call_user_func_array(static::$aliases[$command],$params))
59
+        if (isset(static::$aliases[$command])) {
60
+            if (!$results = call_user_func_array(static::$aliases[$command], $params))
61 61
                 throw new Exception('Shell aliases must return a Shell class or a command string.');
62
-            return $results instanceof static? $results : new static($results);
62
+            return $results instanceof static ? $results : new static($results);
63 63
         } else {
64
-            return new static($command,$params);
64
+            return new static($command, $params);
65 65
         }
66 66
     }
67 67
     
68
-    public function __construct($command,$params=null){
69
-        $this->command = $params?static::_compileCommand($command,$params):$command;
68
+    public function __construct($command, $params = null) {
69
+        $this->command = $params ? static::_compileCommand($command, $params) : $command;
70 70
     }
71 71
     
72
-    public function __toString(){
72
+    public function __toString() {
73 73
         $output = [];
74
-        exec($this->command,$output,$error_code);
75
-        return empty($output)?'':implode(PHP_EOL,$output);
74
+        exec($this->command, $output, $error_code);
75
+        return empty($output) ? '' : implode(PHP_EOL, $output);
76 76
     }
77 77
 
78 78
     /**
79 79
      * Concatenate multiple shell commands via piping
80 80
      * @return Shell The piped shell command
81 81
      */
82
-    public static function pipe(/* ... */){
82
+    public static function pipe(/* ... */) {
83 83
         $cmd = [];
84 84
         foreach (func_get_args() as $item) {
85
-            $cmd[] = ($item instanceof static)?$item->getShellCommand():$item;
85
+            $cmd[] = ($item instanceof static) ? $item->getShellCommand() : $item;
86 86
         }
87
-        return new static(implode(' | ',$cmd));
87
+        return new static(implode(' | ', $cmd));
88 88
     }
89 89
 
90 90
     /**
91 91
      * Concatenate multiple shell commands via logical implication ( && )
92 92
      * @return Shell The concatenated shell command
93 93
      */
94
-    public static function sequence(/* ... */){
94
+    public static function sequence(/* ... */) {
95 95
         $cmd = [];
96 96
         foreach (func_get_args() as $item) {
97
-            $cmd[] = ($item instanceof static)?$item->getShellCommand():$item;
97
+            $cmd[] = ($item instanceof static) ? $item->getShellCommand() : $item;
98 98
         }
99
-        return new static(implode(' && ',$cmd));
99
+        return new static(implode(' && ', $cmd));
100 100
     }
101 101
 
102
-    public static function execCommand($command,$params){
103
-        return new static($command,$params);
102
+    public static function execCommand($command, $params) {
103
+        return new static($command, $params);
104 104
     }
105 105
 
106
-    public static function alias($command,callable $callback){
106
+    public static function alias($command, callable $callback) {
107 107
         static::$aliases[$command] = $callback;
108 108
     }
109 109
 
110
-    public static function escape($arg){
110
+    public static function escape($arg) {
111 111
         return escapeshellarg($arg);
112 112
     }
113 113
 
114
-    public function run(){
114
+    public function run() {
115 115
         return $this->__toString();
116 116
     }
117 117
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -19 removed lines patch added patch discarded remove patch
@@ -22,18 +22,22 @@  discard block
 block discarded – undo
22 22
      * @param array $params 
23 23
      * @return string
24 24
      */
25
-    protected static function _compileCommand($command,array $params){
25
+    protected static function _compileCommand($command,array $params) {
26 26
         $s = $w = [];
27 27
         foreach ($params as $p) {
28 28
             if ($p instanceof static) {
29 29
               $s[] = '$('.$p->getShellCommand().')';
30
-            } else if (is_array($p)) foreach ($p as $key => $value) {
30
+            } else if (is_array($p)) {
31
+              foreach ($p as $key => $value) {
31 32
                 if(is_numeric($key)){
32
-                  $w[] = '--'.$value;                      
33
+                  $w[] = '--'.$value;
34
+            }
33 35
                 } else {
34
-                  if(is_bool($value)){
35
-                     if($value) $w[] = '--'.$key;
36
-                  } else { 
36
+                  if(is_bool($value)) {
37
+                     if($value) {
38
+                       $w[] = '--'.$key;
39
+                     }
40
+                  } else {
37 41
                     $w[] = '--'.$key.'='.escapeshellarg($value);  
38 42
                   }                    
39 43
                 }
@@ -50,26 +54,27 @@  discard block
 block discarded – undo
50 54
      * Returns the compiled shell command
51 55
      * @return string
52 56
      */
53
-    public function getShellCommand(){
57
+    public function getShellCommand() {
54 58
         return $this->command;
55 59
     }
56 60
 
57
-    public static function __callStatic($command,$params){
61
+    public static function __callStatic($command,$params) {
58 62
         // Check if is an alias
59
-        if (isset(static::$aliases[$command])){
60
-            if(!$results = call_user_func_array(static::$aliases[$command],$params))
61
-                throw new Exception('Shell aliases must return a Shell class or a command string.');
63
+        if (isset(static::$aliases[$command])) {
64
+            if(!$results = call_user_func_array(static::$aliases[$command],$params)) {
65
+                            throw new Exception('Shell aliases must return a Shell class or a command string.');
66
+            }
62 67
             return $results instanceof static? $results : new static($results);
63 68
         } else {
64 69
             return new static($command,$params);
65 70
         }
66 71
     }
67 72
     
68
-    public function __construct($command,$params=null){
73
+    public function __construct($command,$params=null) {
69 74
         $this->command = $params?static::_compileCommand($command,$params):$command;
70 75
     }
71 76
     
72
-    public function __toString(){
77
+    public function __toString() {
73 78
         $output = [];
74 79
         exec($this->command,$output,$error_code);
75 80
         return empty($output)?'':implode(PHP_EOL,$output);
@@ -79,7 +84,7 @@  discard block
 block discarded – undo
79 84
      * Concatenate multiple shell commands via piping
80 85
      * @return Shell The piped shell command
81 86
      */
82
-    public static function pipe(/* ... */){
87
+    public static function pipe(/* ... */) {
83 88
         $cmd = [];
84 89
         foreach (func_get_args() as $item) {
85 90
             $cmd[] = ($item instanceof static)?$item->getShellCommand():$item;
@@ -91,7 +96,7 @@  discard block
 block discarded – undo
91 96
      * Concatenate multiple shell commands via logical implication ( && )
92 97
      * @return Shell The concatenated shell command
93 98
      */
94
-    public static function sequence(/* ... */){
99
+    public static function sequence(/* ... */) {
95 100
         $cmd = [];
96 101
         foreach (func_get_args() as $item) {
97 102
             $cmd[] = ($item instanceof static)?$item->getShellCommand():$item;
@@ -99,19 +104,19 @@  discard block
 block discarded – undo
99 104
         return new static(implode(' && ',$cmd));
100 105
     }
101 106
 
102
-    public static function execCommand($command,$params){
107
+    public static function execCommand($command,$params) {
103 108
         return new static($command,$params);
104 109
     }
105 110
 
106
-    public static function alias($command,callable $callback){
111
+    public static function alias($command,callable $callback) {
107 112
         static::$aliases[$command] = $callback;
108 113
     }
109 114
 
110
-    public static function escape($arg){
115
+    public static function escape($arg) {
111 116
         return escapeshellarg($arg);
112 117
     }
113 118
 
114
-    public function run(){
119
+    public function run() {
115 120
         return $this->__toString();
116 121
     }
117 122
 
Please login to merge, or discard this patch.
classes/FileSystem/Native.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -28,6 +28,9 @@
 block discarded – undo
28 28
       return $this->exists($path) ? file_get_contents($this->realPath($path)) : false;
29 29
   }
30 30
 
31
+  /**
32
+   * @param string|false $data
33
+   */
31 34
   public function write($path, $data){
32 35
       $r_path = $this->realPath($path);
33 36
       if ( ! is_dir($r_dir = dirname($r_path)) ) @mkdir($r_dir,0775,true);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -17,42 +17,42 @@  discard block
 block discarded – undo
17 17
   protected $root;
18 18
 
19 19
   public function __construct(array $options = []) {
20
-      $this->root = empty($options['root'])?'/':(rtrim($options['root'],'/').'/');
20
+      $this->root = empty($options['root']) ? '/' : (rtrim($options['root'], '/').'/');
21 21
   }
22 22
 
23
-  public function exists($path){
23
+  public function exists($path) {
24 24
       return file_exists($this->realPath($path));
25 25
   }
26 26
 
27
-  public function read($path){
27
+  public function read($path) {
28 28
       return $this->exists($path) ? file_get_contents($this->realPath($path)) : false;
29 29
   }
30 30
 
31
-  public function write($path, $data){
31
+  public function write($path, $data) {
32 32
       $r_path = $this->realPath($path);
33
-      if ( ! is_dir($r_dir = dirname($r_path)) ) @mkdir($r_dir,0775,true);
33
+      if (!is_dir($r_dir = dirname($r_path))) @mkdir($r_dir, 0775, true);
34 34
       return file_put_contents($r_path, $data);
35 35
   }
36 36
 
37
-  public function append($path, $data){
37
+  public function append($path, $data) {
38 38
       return file_put_contents($this->realPath($path), $data, FILE_APPEND);
39 39
   }
40 40
 
41
-  public function move($old, $new){
41
+  public function move($old, $new) {
42 42
       // Atomic
43
-      if($this->exists($old)){
44
-          return $this->write($new,$this->read($old)) && $this->delete($old);
43
+      if ($this->exists($old)) {
44
+          return $this->write($new, $this->read($old)) && $this->delete($old);
45 45
       } else return false;
46 46
   }
47 47
 
48
-  public function delete($path){
48
+  public function delete($path) {
49 49
       return $this->exists($path) ? unlink($this->realPath($path)) : false;
50 50
   }
51 51
 
52
-  public function search($pattern, $recursive=true){
52
+  public function search($pattern, $recursive = true) {
53 53
       $results    = [];
54 54
       $root_len   = strlen($this->root);
55
-      $rx_pattern = '('.strtr($pattern,['.'=>'\.','*'=>'.*','?'=>'.']).')Ai';
55
+      $rx_pattern = '('.strtr($pattern, ['.'=>'\.', '*'=>'.*', '?'=>'.']).')Ai';
56 56
 
57 57
       /*
58 58
       $files = new \RegexIterator(new \RecursiveDirectoryIterator($this->root,
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
               new \RecursiveDirectoryIterator(
69 69
                   $this->root,
70 70
                   \RecursiveDirectoryIterator::SKIP_DOTS)),
71
-                  $rx_pattern,\RegexIterator::GET_MATCH);
71
+                  $rx_pattern, \RegexIterator::GET_MATCH);
72 72
 
73 73
       $fileList = [];
74
-      foreach($tree as $group) {
75
-          foreach($group as $path) {
76
-              $results[] = trim(substr($path, $root_len),'/');
74
+      foreach ($tree as $group) {
75
+          foreach ($group as $path) {
76
+              $results[] = trim(substr($path, $root_len), '/');
77 77
           }
78 78
       }
79 79
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 
82 82
   }
83 83
 
84
-  protected function realPath($path){
85
-      return $this->root . $path;
84
+  protected function realPath($path) {
85
+      return $this->root.$path;
86 86
   }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,36 +20,40 @@  discard block
 block discarded – undo
20 20
       $this->root = empty($options['root'])?'/':(rtrim($options['root'],'/').'/');
21 21
   }
22 22
 
23
-  public function exists($path){
23
+  public function exists($path) {
24 24
       return file_exists($this->realPath($path));
25 25
   }
26 26
 
27
-  public function read($path){
27
+  public function read($path) {
28 28
       return $this->exists($path) ? file_get_contents($this->realPath($path)) : false;
29 29
   }
30 30
 
31
-  public function write($path, $data){
31
+  public function write($path, $data) {
32 32
       $r_path = $this->realPath($path);
33
-      if ( ! is_dir($r_dir = dirname($r_path)) ) @mkdir($r_dir,0775,true);
33
+      if ( ! is_dir($r_dir = dirname($r_path)) ) {
34
+        @mkdir($r_dir,0775,true);
35
+      }
34 36
       return file_put_contents($r_path, $data);
35 37
   }
36 38
 
37
-  public function append($path, $data){
39
+  public function append($path, $data) {
38 40
       return file_put_contents($this->realPath($path), $data, FILE_APPEND);
39 41
   }
40 42
 
41
-  public function move($old, $new){
43
+  public function move($old, $new) {
42 44
       // Atomic
43
-      if($this->exists($old)){
45
+      if($this->exists($old)) {
44 46
           return $this->write($new,$this->read($old)) && $this->delete($old);
45
-      } else return false;
47
+      } else {
48
+        return false;
49
+      }
46 50
   }
47 51
 
48
-  public function delete($path){
52
+  public function delete($path) {
49 53
       return $this->exists($path) ? unlink($this->realPath($path)) : false;
50 54
   }
51 55
 
52
-  public function search($pattern, $recursive=true){
56
+  public function search($pattern, $recursive=true) {
53 57
       $results    = [];
54 58
       $root_len   = strlen($this->root);
55 59
       $rx_pattern = '('.strtr($pattern,['.'=>'\.','*'=>'.*','?'=>'.']).')Ai';
@@ -81,7 +85,7 @@  discard block
 block discarded – undo
81 85
 
82 86
   }
83 87
 
84
-  protected function realPath($path){
88
+  protected function realPath($path) {
85 89
       return $this->root . $path;
86 90
   }
87 91
 
Please login to merge, or discard this patch.
classes/View/PHP.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -56,6 +56,9 @@
 block discarded – undo
56 56
 class PHPContext {
57 57
   protected $data = [];
58 58
 
59
+  /**
60
+   * @param string $path
61
+   */
59 62
   public function __construct($data=[], $path=null){
60 63
       $this->data = $data;
61 64
   }
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
   const EXTENSION = 'php';
18 18
 
19 19
   protected static $templatePath,
20
-                   $globals = [];
20
+                    $globals = [];
21 21
 
22 22
   public function __construct($path=null,$options=[]){
23 23
       self::$templatePath = ($path ? rtrim($path,'/') : __DIR__) . '/';
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,26 +19,26 @@  discard block
 block discarded – undo
19 19
   protected static $templatePath,
20 20
                    $globals = [];
21 21
 
22
-  public function __construct($path=null,$options=[]){
23
-      self::$templatePath = ($path ? rtrim($path,'/') : __DIR__) . '/';
22
+  public function __construct($path = null, $options = []) {
23
+      self::$templatePath = ($path ? rtrim($path, '/') : __DIR__).'/';
24 24
   }
25 25
 
26
-  public static function exists($path){
26
+  public static function exists($path) {
27 27
       return is_file(self::$templatePath.$path.'.php');
28 28
   }
29 29
 
30
-  public static function addGlobal($key,$val){
30
+  public static function addGlobal($key, $val) {
31 31
     self::$globals[$key] = $val;
32 32
   }
33 33
 
34
-  public static function addGlobals(array $defs){
35
-    foreach ((array)$defs as $key=>$val) {
34
+  public static function addGlobals(array $defs) {
35
+    foreach ((array) $defs as $key=>$val) {
36 36
         self::$globals[$key] = $val;
37 37
     }
38 38
   }
39 39
 
40
-  public function render($template, $data=[]){
41
-      $template_path = self::$templatePath . trim($template,'/') . '.php';
40
+  public function render($template, $data = []) {
41
+      $template_path = self::$templatePath.trim($template, '/').'.php';
42 42
       $sandbox = function() use ($template_path){
43 43
           ob_start();
44 44
           include($template_path);
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
 class PHPContext {
57 57
   protected $data = [];
58 58
 
59
-  public function __construct($data=[], $path=null){
59
+  public function __construct($data = [], $path = null) {
60 60
       $this->data = $data;
61 61
   }
62 62
 
63
-  public function partial($template, $vars=[]){
64
-      return \View::from($template,array_merge($this->data,$vars));
63
+  public function partial($template, $vars = []) {
64
+      return \View::from($template, array_merge($this->data, $vars));
65 65
   }
66 66
 
67
-  public function __isset($n){ return true; }
67
+  public function __isset($n) { return true;}
68 68
 
69
-  public function __unset($n){}
69
+  public function __unset($n) {}
70 70
 
71
-  public function __get($n){
71
+  public function __get($n) {
72 72
     return empty($this->data[$n]) ? '' : $this->data[$n];
73 73
   }
74 74
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
   protected static $templatePath,
20 20
                    $globals = [];
21 21
 
22
-  public function __construct($path=null,$options=[]){
22
+  public function __construct($path=null,$options=[]) {
23 23
       self::$templatePath = ($path ? rtrim($path,'/') : __DIR__) . '/';
24 24
   }
25 25
 
26
-  public static function exists($path){
26
+  public static function exists($path) {
27 27
       return is_file(self::$templatePath.$path.'.php');
28 28
   }
29 29
 
30
-  public static function addGlobal($key,$val){
30
+  public static function addGlobal($key,$val) {
31 31
     self::$globals[$key] = $val;
32 32
   }
33 33
 
34
-  public static function addGlobals(array $defs){
34
+  public static function addGlobals(array $defs) {
35 35
     foreach ((array)$defs as $key=>$val) {
36 36
         self::$globals[$key] = $val;
37 37
     }
38 38
   }
39 39
 
40
-  public function render($template, $data=[]){
40
+  public function render($template, $data=[]) {
41 41
       $template_path = self::$templatePath . trim($template,'/') . '.php';
42
-      $sandbox = function() use ($template_path){
42
+      $sandbox = function() use ($template_path) {
43 43
           ob_start();
44 44
           include($template_path);
45 45
           $__buffer__ = ob_get_contents();
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 class PHPContext {
57 57
   protected $data = [];
58 58
 
59
-  public function __construct($data=[], $path=null){
59
+  public function __construct($data=[], $path=null) {
60 60
       $this->data = $data;
61 61
   }
62 62
 
63
-  public function partial($template, $vars=[]){
63
+  public function partial($template, $vars=[]) {
64 64
       return \View::from($template,array_merge($this->data,$vars));
65 65
   }
66 66
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
   public function __unset($n){}
70 70
 
71
-  public function __get($n){
71
+  public function __get($n) {
72 72
     return empty($this->data[$n]) ? '' : $this->data[$n];
73 73
   }
74 74
 }
Please login to merge, or discard this patch.
classes/Hash.php 3 patches
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -11,151 +11,151 @@
 block discarded – undo
11 11
  */
12 12
 
13 13
 class Hash {
14
-	use Module;
14
+  use Module;
15 15
 
16
-	/**
17
-	 * Create ah hash for payload
18
-	 * @param  mixed $payload The payload string/object/array
19
-	 * @param  integer $method  The hashing method, default is "md5"
20
-	 * @return string          The hash string
21
-	 */
22
-	public static function make($payload, $method = 'md5') {
23
-		return hash($method, serialize($payload));
24
-	}
16
+  /**
17
+   * Create ah hash for payload
18
+   * @param  mixed $payload The payload string/object/array
19
+   * @param  integer $method  The hashing method, default is "md5"
20
+   * @return string          The hash string
21
+   */
22
+  public static function make($payload, $method = 'md5') {
23
+    return hash($method, serialize($payload));
24
+  }
25 25
 
26
-	/**
27
-	 * Verify if given payload matches hash
28
-	 * @param  mixed $payload  The payload string/object/array
29
-	 * @param  string $hash    The hash string
30
-	 * @param  integer $method The hashing method
31
-	 * @return bool            Returns `true` if payload matches hash
32
-	 */
33
-	public static function verify($payload, $hash, $method = 'md5') {
34
-		return static::make($payload, $method) == $hash;
35
-	}
26
+  /**
27
+   * Verify if given payload matches hash
28
+   * @param  mixed $payload  The payload string/object/array
29
+   * @param  string $hash    The hash string
30
+   * @param  integer $method The hashing method
31
+   * @return bool            Returns `true` if payload matches hash
32
+   */
33
+  public static function verify($payload, $hash, $method = 'md5') {
34
+    return static::make($payload, $method) == $hash;
35
+  }
36 36
 
37
-	/**
38
-	 * List registered hashing algorithms
39
-	 *
40
-	 * @method methods
41
-	 *
42
-	 * @return array   Array containing the list of supported hashing algorithms.
43
-	 */
44
-	public static function methods() {
45
-		return hash_algos();
46
-	}
37
+  /**
38
+   * List registered hashing algorithms
39
+   *
40
+   * @method methods
41
+   *
42
+   * @return array   Array containing the list of supported hashing algorithms.
43
+   */
44
+  public static function methods() {
45
+    return hash_algos();
46
+  }
47 47
 
48
-	/**
49
-	 * Check if an alghoritm is registered in current PHP
50
-	 *
51
-	 * @method can
52
-	 *
53
-	 * @param  string $algo The hashing algorithm name
54
-	 *
55
-	 * @return bool
56
-	 */
57
-	public static function can($algo) {
58
-		return in_array($algo, hash_algos());
59
-	}
48
+  /**
49
+   * Check if an alghoritm is registered in current PHP
50
+   *
51
+   * @method can
52
+   *
53
+   * @param  string $algo The hashing algorithm name
54
+   *
55
+   * @return bool
56
+   */
57
+  public static function can($algo) {
58
+    return in_array($algo, hash_algos());
59
+  }
60 60
 
61
-	/**
62
-	 * Static magic for creating hashes with a specified algorithm.
63
-	 *
64
-	 * See [hash-algos](http://php.net/manual/it/function.hash-algos.php) for a list of algorithms
65
-	 */
66
-	public static function __callStatic($method, $params) {
67
-		return self::make(current($params), $method);
68
-	}
61
+  /**
62
+   * Static magic for creating hashes with a specified algorithm.
63
+   *
64
+   * See [hash-algos](http://php.net/manual/it/function.hash-algos.php) for a list of algorithms
65
+   */
66
+  public static function __callStatic($method, $params) {
67
+    return self::make(current($params), $method);
68
+  }
69 69
 
70
-	public static function uuid($type = 4, $namespace = '', $name = '') {
71
-		switch ($type) {
72
-		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
73
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
74
-				return false;
75
-			}
70
+  public static function uuid($type = 4, $namespace = '', $name = '') {
71
+    switch ($type) {
72
+    case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
73
+        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
74
+        return false;
75
+      }
76 76
 
77
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
78
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
79
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
80
-			}
77
+      $nhex = str_replace(array('-', '{', '}'), '', $namespace);
78
+      $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
79
+        $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
80
+      }
81 81
 
82
-			$hash = md5($nstr . $name);
83
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
84
-				substr($hash, 0, 8), substr($hash, 8, 4),
85
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
86
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
87
-				substr($hash, 20, 12));
88
-		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
89
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
90
-				return false;
91
-			}
82
+      $hash = md5($nstr . $name);
83
+      return sprintf('%08s-%04s-%04x-%04x-%12s',
84
+        substr($hash, 0, 8), substr($hash, 8, 4),
85
+        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
86
+        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
87
+        substr($hash, 20, 12));
88
+    case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
89
+        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
90
+        return false;
91
+      }
92 92
 
93
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
94
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
95
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
96
-			}
93
+      $nhex = str_replace(array('-', '{', '}'), '', $namespace);
94
+      $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
95
+        $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
96
+      }
97 97
 
98
-			$hash = sha1($nstr . $name);
99
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
100
-				substr($hash, 0, 8), substr($hash, 8, 4),
101
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
102
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
103
-				substr($hash, 20, 12));
104
-		default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
105
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
106
-				mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
107
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
108
-		}
109
-	}
98
+      $hash = sha1($nstr . $name);
99
+      return sprintf('%08s-%04s-%04x-%04x-%12s',
100
+        substr($hash, 0, 8), substr($hash, 8, 4),
101
+        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
102
+        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
103
+        substr($hash, 20, 12));
104
+    default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
105
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
106
+        mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
107
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
108
+    }
109
+  }
110 110
 
111
-	public static function murmurhash3_int($key, $seed = 0) {
112
-		$key = (string) $key;
113
-		$klen = strlen($key);
114
-		$h1 = $seed;
115
-		for ($i = 0, $bytes = $klen - ($remainder = $klen & 3); $i < $bytes;) {
116
-			$k1 = ((ord($key[$i]) & 0xff))
117
-			 | ((ord($key[++$i]) & 0xff) << 8)
118
-			 | ((ord($key[++$i]) & 0xff) << 16)
119
-			 | ((ord($key[++$i]) & 0xff) << 24);
120
-			++$i;
121
-			$k1 = (((($k1 & 0xffff) * 0xcc9e2d51)
122
-				 + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000)) * 0xcc9e2d51) & 0xffff) << 16)))
123
-			 & 0xffffffff;
124
-			$k1 = $k1 << 15 | ($k1 >= 0 ? $k1 >> 17 : (($k1 & 0x7fffffff) >> 17) | 0x4000);
125
-			$k1 = (((($k1 & 0xffff) * 0x1b873593) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
126
-				 * 0x1b873593) & 0xffff) << 16))) & 0xffffffff;
127
-			$h1 ^= $k1;
128
-			$h1 = $h1 << 13 | ($h1 >= 0 ? $h1 >> 19 : (($h1 & 0x7fffffff) >> 19) | 0x1000);
129
-			$h1b = (((($h1 & 0xffff) * 5) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000)) * 5)
130
-				 & 0xffff) << 16))) & 0xffffffff;
131
-			$h1 = ((($h1b & 0xffff) + 0x6b64) + ((((($h1b >= 0 ? $h1b >> 16 : (($h1b & 0x7fffffff) >> 16) | 0x8000))
132
-				 + 0xe654) & 0xffff) << 16));
133
-		}
134
-		$k1 = 0;
135
-		switch ($remainder) {
136
-		case 3:$k1 ^= (ord($key[$i + 2]) & 0xff) << 16;
137
-		case 2:$k1 ^= (ord($key[$i + 1]) & 0xff) << 8;
138
-		case 1:$k1 ^= (ord($key[$i]) & 0xff);
139
-			$k1 = ((($k1 & 0xffff) * 0xcc9e2d51) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
140
-				 * 0xcc9e2d51) & 0xffff) << 16)) & 0xffffffff;
141
-			$k1 = $k1 << 15 | ($k1 >= 0 ? $k1 >> 17 : (($k1 & 0x7fffffff) >> 17) | 0x4000);
142
-			$k1 = ((($k1 & 0xffff) * 0x1b873593) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
143
-				 * 0x1b873593) & 0xffff) << 16)) & 0xffffffff;
144
-			$h1 ^= $k1;
145
-		}
146
-		$h1 ^= $klen;
147
-		$h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
148
-		$h1 = ((($h1 & 0xffff) * 0x85ebca6b) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000))
149
-			 * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
150
-		$h1 ^= ($h1 >= 0 ? $h1 >> 13 : (($h1 & 0x7fffffff) >> 13) | 0x40000);
151
-		$h1 = (((($h1 & 0xffff) * 0xc2b2ae35) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000))
152
-			 * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
153
-		$h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
154
-		return $h1;
155
-	}
111
+  public static function murmurhash3_int($key, $seed = 0) {
112
+    $key = (string) $key;
113
+    $klen = strlen($key);
114
+    $h1 = $seed;
115
+    for ($i = 0, $bytes = $klen - ($remainder = $klen & 3); $i < $bytes;) {
116
+      $k1 = ((ord($key[$i]) & 0xff))
117
+        | ((ord($key[++$i]) & 0xff) << 8)
118
+        | ((ord($key[++$i]) & 0xff) << 16)
119
+        | ((ord($key[++$i]) & 0xff) << 24);
120
+      ++$i;
121
+      $k1 = (((($k1 & 0xffff) * 0xcc9e2d51)
122
+         + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000)) * 0xcc9e2d51) & 0xffff) << 16)))
123
+        & 0xffffffff;
124
+      $k1 = $k1 << 15 | ($k1 >= 0 ? $k1 >> 17 : (($k1 & 0x7fffffff) >> 17) | 0x4000);
125
+      $k1 = (((($k1 & 0xffff) * 0x1b873593) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
126
+         * 0x1b873593) & 0xffff) << 16))) & 0xffffffff;
127
+      $h1 ^= $k1;
128
+      $h1 = $h1 << 13 | ($h1 >= 0 ? $h1 >> 19 : (($h1 & 0x7fffffff) >> 19) | 0x1000);
129
+      $h1b = (((($h1 & 0xffff) * 5) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000)) * 5)
130
+          & 0xffff) << 16))) & 0xffffffff;
131
+      $h1 = ((($h1b & 0xffff) + 0x6b64) + ((((($h1b >= 0 ? $h1b >> 16 : (($h1b & 0x7fffffff) >> 16) | 0x8000))
132
+         + 0xe654) & 0xffff) << 16));
133
+    }
134
+    $k1 = 0;
135
+    switch ($remainder) {
136
+    case 3:$k1 ^= (ord($key[$i + 2]) & 0xff) << 16;
137
+    case 2:$k1 ^= (ord($key[$i + 1]) & 0xff) << 8;
138
+    case 1:$k1 ^= (ord($key[$i]) & 0xff);
139
+      $k1 = ((($k1 & 0xffff) * 0xcc9e2d51) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
140
+         * 0xcc9e2d51) & 0xffff) << 16)) & 0xffffffff;
141
+      $k1 = $k1 << 15 | ($k1 >= 0 ? $k1 >> 17 : (($k1 & 0x7fffffff) >> 17) | 0x4000);
142
+      $k1 = ((($k1 & 0xffff) * 0x1b873593) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
143
+         * 0x1b873593) & 0xffff) << 16)) & 0xffffffff;
144
+      $h1 ^= $k1;
145
+    }
146
+    $h1 ^= $klen;
147
+    $h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
148
+    $h1 = ((($h1 & 0xffff) * 0x85ebca6b) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000))
149
+       * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
150
+    $h1 ^= ($h1 >= 0 ? $h1 >> 13 : (($h1 & 0x7fffffff) >> 13) | 0x40000);
151
+    $h1 = (((($h1 & 0xffff) * 0xc2b2ae35) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000))
152
+       * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
153
+    $h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
154
+    return $h1;
155
+  }
156 156
 
157
-	public static function murmurhash3($key, $seed = 0) {
158
-		return base_convert(static::murmurhash3_int($key, $seed), 10, 32);
159
-	}
157
+  public static function murmurhash3($key, $seed = 0) {
158
+    return base_convert(static::murmurhash3_int($key, $seed), 10, 32);
159
+  }
160 160
 
161 161
 }
Please login to merge, or discard this patch.
Switch Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -69,42 +69,42 @@  discard block
 block discarded – undo
69 69
 
70 70
 	public static function uuid($type = 4, $namespace = '', $name = '') {
71 71
 		switch ($type) {
72
-		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
73
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
74
-				return false;
75
-			}
72
+		  case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
73
+				  '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
74
+				  return false;
75
+			  }
76 76
 
77
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
78
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
79
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
80
-			}
77
+			  $nhex = str_replace(array('-', '{', '}'), '', $namespace);
78
+			  $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
79
+				  $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
80
+			  }
81 81
 
82
-			$hash = md5($nstr . $name);
83
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
84
-				substr($hash, 0, 8), substr($hash, 8, 4),
85
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
86
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
87
-				substr($hash, 20, 12));
88
-		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
89
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
90
-				return false;
91
-			}
82
+			  $hash = md5($nstr . $name);
83
+			  return sprintf('%08s-%04s-%04x-%04x-%12s',
84
+				  substr($hash, 0, 8), substr($hash, 8, 4),
85
+				  (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
86
+				  (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
87
+				  substr($hash, 20, 12));
88
+		  case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
89
+				  '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
90
+				  return false;
91
+			  }
92 92
 
93
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
94
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
95
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
96
-			}
93
+			  $nhex = str_replace(array('-', '{', '}'), '', $namespace);
94
+			  $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
95
+				  $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
96
+			  }
97 97
 
98
-			$hash = sha1($nstr . $name);
99
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
100
-				substr($hash, 0, 8), substr($hash, 8, 4),
101
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
102
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
103
-				substr($hash, 20, 12));
104
-		default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
105
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
106
-				mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
107
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
98
+			  $hash = sha1($nstr . $name);
99
+			  return sprintf('%08s-%04s-%04x-%04x-%12s',
100
+				  substr($hash, 0, 8), substr($hash, 8, 4),
101
+				  (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
102
+				  (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
103
+				  substr($hash, 20, 12));
104
+		  default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
105
+				  mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
106
+				  mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
107
+				  mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
108 108
 		}
109 109
 	}
110 110
 
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 		}
134 134
 		$k1 = 0;
135 135
 		switch ($remainder) {
136
-		case 3:$k1 ^= (ord($key[$i + 2]) & 0xff) << 16;
137
-		case 2:$k1 ^= (ord($key[$i + 1]) & 0xff) << 8;
138
-		case 1:$k1 ^= (ord($key[$i]) & 0xff);
139
-			$k1 = ((($k1 & 0xffff) * 0xcc9e2d51) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
140
-				 * 0xcc9e2d51) & 0xffff) << 16)) & 0xffffffff;
141
-			$k1 = $k1 << 15 | ($k1 >= 0 ? $k1 >> 17 : (($k1 & 0x7fffffff) >> 17) | 0x4000);
142
-			$k1 = ((($k1 & 0xffff) * 0x1b873593) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
143
-				 * 0x1b873593) & 0xffff) << 16)) & 0xffffffff;
144
-			$h1 ^= $k1;
136
+		  case 3:$k1 ^= (ord($key[$i + 2]) & 0xff) << 16;
137
+		  case 2:$k1 ^= (ord($key[$i + 1]) & 0xff) << 8;
138
+		  case 1:$k1 ^= (ord($key[$i]) & 0xff);
139
+			  $k1 = ((($k1 & 0xffff) * 0xcc9e2d51) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
140
+				   * 0xcc9e2d51) & 0xffff) << 16)) & 0xffffffff;
141
+			  $k1 = $k1 << 15 | ($k1 >= 0 ? $k1 >> 17 : (($k1 & 0x7fffffff) >> 17) | 0x4000);
142
+			  $k1 = ((($k1 & 0xffff) * 0x1b873593) + ((((($k1 >= 0 ? $k1 >> 16 : (($k1 & 0x7fffffff) >> 16) | 0x8000))
143
+				   * 0x1b873593) & 0xffff) << 16)) & 0xffffffff;
144
+			  $h1 ^= $k1;
145 145
 		}
146 146
 		$h1 ^= $klen;
147 147
 		$h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,33 +69,33 @@  discard block
 block discarded – undo
69 69
 
70 70
 	public static function uuid($type = 4, $namespace = '', $name = '') {
71 71
 		switch ($type) {
72
-		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
72
+		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
73 73
 				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
74 74
 				return false;
75 75
 			}
76 76
 
77 77
 			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
78
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
79
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
78
+			$nstr = '';for ($i = 0;$i < strlen($nhex);$i += 2) {
79
+				$nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
80 80
 			}
81 81
 
82
-			$hash = md5($nstr . $name);
82
+			$hash = md5($nstr.$name);
83 83
 			return sprintf('%08s-%04s-%04x-%04x-%12s',
84 84
 				substr($hash, 0, 8), substr($hash, 8, 4),
85 85
 				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
86 86
 				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
87 87
 				substr($hash, 20, 12));
88
-		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
88
+		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
89 89
 				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
90 90
 				return false;
91 91
 			}
92 92
 
93 93
 			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
94
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
95
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
94
+			$nstr = '';for ($i = 0;$i < strlen($nhex);$i += 2) {
95
+				$nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
96 96
 			}
97 97
 
98
-			$hash = sha1($nstr . $name);
98
+			$hash = sha1($nstr.$name);
99 99
 			return sprintf('%08s-%04s-%04x-%04x-%12s',
100 100
 				substr($hash, 0, 8), substr($hash, 8, 4),
101 101
 				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		$key = (string) $key;
113 113
 		$klen = strlen($key);
114 114
 		$h1 = $seed;
115
-		for ($i = 0, $bytes = $klen - ($remainder = $klen & 3); $i < $bytes;) {
115
+		for ($i = 0, $bytes = $klen - ($remainder = $klen & 3);$i < $bytes;) {
116 116
 			$k1 = ((ord($key[$i]) & 0xff))
117 117
 			 | ((ord($key[++$i]) & 0xff) << 8)
118 118
 			 | ((ord($key[++$i]) & 0xff) << 16)
Please login to merge, or discard this patch.
classes/FileSystem/ZIP.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,50 +19,50 @@
 block discarded – undo
19 19
             $fileCache;
20 20
 
21 21
   public function __construct(array $options = []) {
22
-      $this->path    = empty($options['root'])?(tempnam(sys_get_temp_dir(), 'CFZ_').'.zip'):rtrim($options['root']);
22
+      $this->path    = empty($options['root']) ? (tempnam(sys_get_temp_dir(), 'CFZ_').'.zip') : rtrim($options['root']);
23 23
       $this->zipfile = new \ZipArchive();
24
-      if ( !$this->zipfile->open($this->path, \ZipArchive::CREATE) ){
24
+      if (!$this->zipfile->open($this->path, \ZipArchive::CREATE)) {
25 25
           throw new \Exception("File::ZIP Cannot open or create ".$this->path);
26 26
       }
27 27
   }
28 28
 
29
-  public function exists($path){
29
+  public function exists($path) {
30 30
       return false !== $this->zipfile->locateName($path);
31 31
   }
32 32
 
33
-  public function read($path){
33
+  public function read($path) {
34 34
       if (isset($this->fileCache[$path])) return $this->fileCache[$path];
35 35
       return $this->exists($path) ? $this->zipfile->getFromName($path) : false;
36 36
   }
37 37
 
38
-  public function write($path, $data){
38
+  public function write($path, $data) {
39 39
       // This is needed because we cant write and read from the same archive.
40 40
       $this->fileCache[$path] = $data;
41 41
       return $this->zipfile->addFromString($path, $data);
42 42
   }
43 43
 
44
-  public function append($path, $data){
45
-      return $this->write($path, ($this->read($path) ?: '') . $data);
44
+  public function append($path, $data) {
45
+      return $this->write($path, ($this->read($path) ?: '').$data);
46 46
   }
47 47
 
48
-  public function delete($path){
48
+  public function delete($path) {
49 49
       return $this->exists($path) ? $this->zipfile->deleteName($path) : false;
50 50
   }
51 51
 
52
-  public function move($old, $new){
52
+  public function move($old, $new) {
53 53
       // Atomic rename
54 54
       // This is needed because we cant write and read from the same archive.
55
-      return $this->write($new,$this->read($old)) && $this->delete($old);
55
+      return $this->write($new, $this->read($old)) && $this->delete($old);
56 56
       // return $this->zipfile->renameName($old, $new);
57 57
   }
58 58
 
59
-  public function search($pattern, $recursive=true){
59
+  public function search($pattern, $recursive = true) {
60 60
       $results = [];
61
-      $rx_pattern = '('.strtr($pattern,['.'=>'\.','*'=>'.*','?'=>'.']).')Ai';
61
+      $rx_pattern = '('.strtr($pattern, ['.'=>'\.', '*'=>'.*', '?'=>'.']).')Ai';
62 62
 
63
-      for( $i = 0, $c = $this->zipfile->numFiles; $i < $c; $i++ ){
64
-          $stat = $this->zipfile->statIndex( $i );
65
-          if (preg_match($rx_pattern,$stat['name'])) $results[] = $stat['name'];
63
+      for ($i = 0, $c = $this->zipfile->numFiles;$i < $c;$i++) {
64
+          $stat = $this->zipfile->statIndex($i);
65
+          if (preg_match($rx_pattern, $stat['name'])) $results[] = $stat['name'];
66 66
       }
67 67
 
68 68
       return $results;
Please login to merge, or discard this patch.
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,48 +21,52 @@
 block discarded – undo
21 21
   public function __construct(array $options = []) {
22 22
       $this->path    = empty($options['root'])?(tempnam(sys_get_temp_dir(), 'CFZ_').'.zip'):rtrim($options['root']);
23 23
       $this->zipfile = new \ZipArchive();
24
-      if ( !$this->zipfile->open($this->path, \ZipArchive::CREATE) ){
24
+      if ( !$this->zipfile->open($this->path, \ZipArchive::CREATE) ) {
25 25
           throw new \Exception("File::ZIP Cannot open or create ".$this->path);
26 26
       }
27 27
   }
28 28
 
29
-  public function exists($path){
29
+  public function exists($path) {
30 30
       return false !== $this->zipfile->locateName($path);
31 31
   }
32 32
 
33
-  public function read($path){
34
-      if (isset($this->fileCache[$path])) return $this->fileCache[$path];
33
+  public function read($path) {
34
+      if (isset($this->fileCache[$path])) {
35
+        return $this->fileCache[$path];
36
+      }
35 37
       return $this->exists($path) ? $this->zipfile->getFromName($path) : false;
36 38
   }
37 39
 
38
-  public function write($path, $data){
40
+  public function write($path, $data) {
39 41
       // This is needed because we cant write and read from the same archive.
40 42
       $this->fileCache[$path] = $data;
41 43
       return $this->zipfile->addFromString($path, $data);
42 44
   }
43 45
 
44
-  public function append($path, $data){
46
+  public function append($path, $data) {
45 47
       return $this->write($path, ($this->read($path) ?: '') . $data);
46 48
   }
47 49
 
48
-  public function delete($path){
50
+  public function delete($path) {
49 51
       return $this->exists($path) ? $this->zipfile->deleteName($path) : false;
50 52
   }
51 53
 
52
-  public function move($old, $new){
54
+  public function move($old, $new) {
53 55
       // Atomic rename
54 56
       // This is needed because we cant write and read from the same archive.
55 57
       return $this->write($new,$this->read($old)) && $this->delete($old);
56 58
       // return $this->zipfile->renameName($old, $new);
57 59
   }
58 60
 
59
-  public function search($pattern, $recursive=true){
61
+  public function search($pattern, $recursive=true) {
60 62
       $results = [];
61 63
       $rx_pattern = '('.strtr($pattern,['.'=>'\.','*'=>'.*','?'=>'.']).')Ai';
62 64
 
63
-      for( $i = 0, $c = $this->zipfile->numFiles; $i < $c; $i++ ){
65
+      for( $i = 0, $c = $this->zipfile->numFiles; $i < $c; $i++ ) {
64 66
           $stat = $this->zipfile->statIndex( $i );
65
-          if (preg_match($rx_pattern,$stat['name'])) $results[] = $stat['name'];
67
+          if (preg_match($rx_pattern,$stat['name'])) {
68
+            $results[] = $stat['name'];
69
+          }
66 70
       }
67 71
 
68 72
       return $results;
Please login to merge, or discard this patch.
classes/View/Adapter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
 namespace View;
14 14
 
15 15
 interface Adapter {
16
-    public function __construct($path=null, $options=[]);
17
-    public function render($template,$data=[]);
16
+    public function __construct($path = null, $options = []);
17
+    public function render($template, $data = []);
18 18
     public static function exists($path);
19
-    public static function addGlobal($key,$val);
19
+    public static function addGlobal($key, $val);
20 20
     public static function addGlobals(array $defs);
21 21
 }
Please login to merge, or discard this patch.
classes/Deferred.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 
13 13
 class Deferred {
14 14
 
15
-	protected $callback,
15
+  protected $callback,
16 16
             $enabled = true;
17 17
 
18
-	public function __construct( callable $callback ) {
19
-		$this->callback = $callback;
20
-	}
18
+  public function __construct( callable $callback ) {
19
+    $this->callback = $callback;
20
+  }
21 21
 
22 22
   public function disarm() {
23 23
     $this->enabled = false;
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
     $this->enabled = true;
28 28
   }
29 29
 
30
-	public function __destruct() {
31
-		if ( $this->enabled ) call_user_func( $this->callback );
32
-	}
30
+  public function __destruct() {
31
+    if ( $this->enabled ) call_user_func( $this->callback );
32
+  }
33 33
 
34 34
 }
35 35
\ No newline at end of file
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
 	protected $callback,
16 16
             $enabled = true;
17 17
 
18
-	public function __construct( callable $callback ) {
18
+	public function __construct(callable $callback) {
19 19
 		$this->callback = $callback;
20 20
 	}
21 21
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
   }
29 29
 
30 30
 	public function __destruct() {
31
-		if ( $this->enabled ) call_user_func( $this->callback );
31
+		if ($this->enabled) call_user_func($this->callback);
32 32
 	}
33 33
 
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@
 block discarded – undo
28 28
   }
29 29
 
30 30
 	public function __destruct() {
31
-		if ( $this->enabled ) call_user_func( $this->callback );
31
+		if ( $this->enabled ) {
32
+		  call_user_func( $this->callback );
33
+		}
32 34
 	}
33 35
 
34 36
 }
35 37
\ No newline at end of file
Please login to merge, or discard this patch.