Completed
Push — master ( f98586...bb34f0 )
by Stefano
03:08
created
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.
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.
Spacing   +15 added lines, -15 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){
27
-      return is_file(self::$templatePath . $path . static::EXTENSION);
26
+  public static function exists($path) {
27
+      return is_file(self::$templatePath.$path.static::EXTENSION);
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,'/') . static::EXTENSION;
40
+  public function render($template, $data = []) {
41
+      $template_path = self::$templatePath.trim($template, '/').static::EXTENSION;
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.
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.
classes/Filter.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
     protected static $_modders = [];
17 17
 
18
-    public static function add($name,callable $modder = null){
19
-        if( is_array($name) ) {
18
+    public static function add($name, callable $modder = null) {
19
+        if (is_array($name)) {
20 20
             foreach ($name as $key => $value) {
21 21
                 static::$_modders[$key][] = $value;
22 22
             }
@@ -25,26 +25,26 @@  discard block
 block discarded – undo
25 25
         }
26 26
     }
27 27
 
28
-    public static function single($name,callable $modder){
28
+    public static function single($name, callable $modder) {
29 29
         static::$_modders[$name] = [$modder];
30 30
     }
31 31
 
32
-    public static function remove($name,callable $modder = null){
33
-        if($modder === null) {
32
+    public static function remove($name, callable $modder = null) {
33
+        if ($modder === null) {
34 34
             unset(static::$_modders[$name]);
35 35
         } else {
36
-            if ($idx = array_search($modder,static::$_modders[$name],true))
36
+            if ($idx = array_search($modder, static::$_modders[$name], true))
37 37
                 unset(static::$_modders[$name][$idx]);
38 38
         }
39 39
     }
40 40
 
41
-    public static function with($names, $default){
42
-      foreach ((array)$names as $name) {
41
+    public static function with($names, $default) {
42
+      foreach ((array) $names as $name) {
43 43
         if (!empty(static::$_modders[$name])) {
44 44
             $value = $default;
45
-            $args = array_slice( func_get_args(), 2 );
45
+            $args = array_slice(func_get_args(), 2);
46 46
             foreach (static::$_modders[$name] as $modder) {
47
-                $value = call_user_func( $modder,$value,$args );
47
+                $value = call_user_func($modder, $value, $args);
48 48
             }
49 49
             return $value;
50 50
         }
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     protected static $_modders = [];
17 17
 
18
-    public static function add($name,callable $modder = null){
18
+    public static function add($name,callable $modder = null) {
19 19
         if( is_array($name) ) {
20 20
             foreach ($name as $key => $value) {
21 21
                 static::$_modders[$key][] = $value;
@@ -25,20 +25,21 @@  discard block
 block discarded – undo
25 25
         }
26 26
     }
27 27
 
28
-    public static function single($name,callable $modder){
28
+    public static function single($name,callable $modder) {
29 29
         static::$_modders[$name] = [$modder];
30 30
     }
31 31
 
32
-    public static function remove($name,callable $modder = null){
32
+    public static function remove($name,callable $modder = null) {
33 33
         if($modder === null) {
34 34
             unset(static::$_modders[$name]);
35 35
         } else {
36
-            if ($idx = array_search($modder,static::$_modders[$name],true))
37
-                unset(static::$_modders[$name][$idx]);
36
+            if ($idx = array_search($modder,static::$_modders[$name],true)) {
37
+                            unset(static::$_modders[$name][$idx]);
38
+            }
38 39
         }
39 40
     }
40 41
 
41
-    public static function with($names, $default){
42
+    public static function with($names, $default) {
42 43
       foreach ((array)$names as $name) {
43 44
         if (!empty(static::$_modders[$name])) {
44 45
             $value = $default;
Please login to merge, or discard this patch.
classes/Text.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
    * @param mixed $t  The text template
27 27
    * @param mixed $v (default: null)  The array of values exposed in template.
28 28
    * @return string
29
-  */
29
+   */
30 30
   public static function render($t,$v=null){
31 31
     if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t);
32 32
     for(  // Init
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    * @param mixed $v (default: null)  The array of values exposed in template.
28 28
    * @return string
29 29
   */
30
-  public static function render($t,$v=null){
30
+  public static function render($t, $v = null) {
31 31
     if (Options::get('core.text.replace_empties', true)) {
32 32
       $replacer = function($c) use ($v){
33 33
         return Object::fetch(trim($c[1]), $v);
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
       };
39 39
     }
40 40
 
41
-    return preg_replace_callback("(\{\{([^}]+)\}\})S",$replacer,$t);
41
+    return preg_replace_callback("(\{\{([^}]+)\}\})S", $replacer, $t);
42 42
   }
43 43
 
44 44
   /**
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
    * @param  string $text The text to slugify
54 54
    * @return string       The slug.
55 55
    */
56
-  public static function slugify($text){
56
+  public static function slugify($text) {
57 57
     return preg_replace(
58
-      ['(\s+)','([^a-z0-9-])i','(-+)'],['-','','-'],
58
+      ['(\s+)', '([^a-z0-9-])i', '(-+)'], ['-', '', '-'],
59 59
       strtolower(self::removeAccents($text)));
60 60
   }
61 61
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
    * @param  string $text The text to translit
72 72
    * @return string       The translited text
73 73
    */
74
-  public static function removeAccents($text){
74
+  public static function removeAccents($text) {
75 75
     static $diac;
76 76
     return strtr(
77 77
       utf8_decode($text),
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
    * @param mixed $v (default: null)  The array of values exposed in template.
28 28
    * @return string
29 29
   */
30
-  public static function render($t,$v=null){
30
+  public static function render($t,$v=null) {
31 31
     if (Options::get('core.text.replace_empties', true)) {
32
-      $replacer = function($c) use ($v){
32
+      $replacer = function($c) use ($v) {
33 33
         return Object::fetch(trim($c[1]), $v);
34 34
       };
35 35
     } else {
36
-      $replacer = function($c) use ($v){
36
+      $replacer = function($c) use ($v) {
37 37
         return Object::fetch(trim($c[1]), $v) ?: $c[0];
38 38
       };
39 39
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
    * @param  string $text The text to slugify
54 54
    * @return string       The slug.
55 55
    */
56
-  public static function slugify($text){
56
+  public static function slugify($text) {
57 57
     return preg_replace(
58 58
       ['(\s+)','([^a-z0-9-])i','(-+)'],['-','','-'],
59 59
       strtolower(self::removeAccents($text)));
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
    * @param  string $text The text to translit
72 72
    * @return string       The translited text
73 73
    */
74
-  public static function removeAccents($text){
74
+  public static function removeAccents($text) {
75 75
     static $diac;
76 76
     return strtr(
77 77
       utf8_decode($text),
Please login to merge, or discard this patch.
classes/Dictionary.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
         return static::$fields->all();
28 28
     }
29 29
 
30
-    public static function get($key, $default=null){
30
+    public static function get($key, $default = null) {
31 31
         if (!static::$fields) static::$fields = new Map();
32
-        if (is_array($key)){
32
+        if (is_array($key)) {
33 33
           $results = [];
34 34
           foreach ($key as $_src_key => $_dst_key)
35 35
             $results[$_dst_key] = static::$fields->get($_src_key);
@@ -39,46 +39,46 @@  discard block
 block discarded – undo
39 39
         }
40 40
     }
41 41
 
42
-    public static function set($key, $value=null){
42
+    public static function set($key, $value = null) {
43 43
         if (!static::$fields) static::$fields = new Map();
44 44
         return static::$fields->set($key, $value);
45 45
     }
46 46
 
47
-    public static function delete($key, $compact=true){
47
+    public static function delete($key, $compact = true) {
48 48
         if (!static::$fields) static::$fields = new Map();
49 49
         static::$fields->delete($key, $compact);
50 50
     }
51 51
 
52
-    public static function exists($key){
52
+    public static function exists($key) {
53 53
         if (!static::$fields) static::$fields = new Map();
54 54
         return static::$fields->exists($key);
55 55
     }
56 56
 
57
-    public static function clear(){
57
+    public static function clear() {
58 58
         if (!static::$fields) static::$fields = new Map();
59 59
         static::$fields->clear();
60 60
     }
61 61
 
62
-    public static function load($fields){
62
+    public static function load($fields) {
63 63
         if (!static::$fields) static::$fields = new Map();
64 64
         static::$fields->load($fields);
65 65
     }
66 66
 
67
-    public static function merge(array $array, $merge_back=false){
67
+    public static function merge(array $array, $merge_back = false) {
68 68
         if (!static::$fields) static::$fields = new Map();
69 69
         static::$fields->merge($array, $merge_back);
70 70
     }
71 71
 
72
-    protected static function compact(){
72
+    protected static function compact() {
73 73
         if (!static::$fields) static::$fields = new Map();
74 74
         static::$fields->compact();
75 75
     }
76 76
 
77
-    protected static function & find($path, $create=false, callable $operation=null) {
77
+    protected static function & find($path, $create = false, callable $operation = null) {
78 78
         return static::$fields->find($path, $create, $operation);
79 79
     }
80 80
 
81
-    public function jsonSerialize(){
81
+    public function jsonSerialize() {
82 82
       if (!static::$fields) static::$fields = new Map();
83 83
       return static::$fields->jsonSerialize();
84 84
     }
Please login to merge, or discard this patch.
Braces   +40 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,13 +23,17 @@  discard block
 block discarded – undo
23 23
     protected static $fields = null;
24 24
 
25 25
     public static function & all(){
26
-        if (!static::$fields) static::$fields = new Map();
26
+        if (!static::$fields) {
27
+          static::$fields = new Map();
28
+        }
27 29
         return static::$fields->all();
28 30
     }
29 31
 
30
-    public static function get($key, $default=null){
31
-        if (!static::$fields) static::$fields = new Map();
32
-        if (is_array($key)){
32
+    public static function get($key, $default=null) {
33
+        if (!static::$fields) {
34
+          static::$fields = new Map();
35
+        }
36
+        if (is_array($key)) {
33 37
           $results = [];
34 38
           foreach ($key as $_src_key => $_dst_key)
35 39
             $results[$_dst_key] = static::$fields->get($_src_key);
@@ -39,38 +43,52 @@  discard block
 block discarded – undo
39 43
         }
40 44
     }
41 45
 
42
-    public static function set($key, $value=null){
43
-        if (!static::$fields) static::$fields = new Map();
46
+    public static function set($key, $value=null) {
47
+        if (!static::$fields) {
48
+          static::$fields = new Map();
49
+        }
44 50
         return static::$fields->set($key, $value);
45 51
     }
46 52
 
47
-    public static function delete($key, $compact=true){
48
-        if (!static::$fields) static::$fields = new Map();
53
+    public static function delete($key, $compact=true) {
54
+        if (!static::$fields) {
55
+          static::$fields = new Map();
56
+        }
49 57
         static::$fields->delete($key, $compact);
50 58
     }
51 59
 
52
-    public static function exists($key){
53
-        if (!static::$fields) static::$fields = new Map();
60
+    public static function exists($key) {
61
+        if (!static::$fields) {
62
+          static::$fields = new Map();
63
+        }
54 64
         return static::$fields->exists($key);
55 65
     }
56 66
 
57
-    public static function clear(){
58
-        if (!static::$fields) static::$fields = new Map();
67
+    public static function clear() {
68
+        if (!static::$fields) {
69
+          static::$fields = new Map();
70
+        }
59 71
         static::$fields->clear();
60 72
     }
61 73
 
62
-    public static function load($fields){
63
-        if (!static::$fields) static::$fields = new Map();
74
+    public static function load($fields) {
75
+        if (!static::$fields) {
76
+          static::$fields = new Map();
77
+        }
64 78
         static::$fields->load($fields);
65 79
     }
66 80
 
67
-    public static function merge(array $array, $merge_back=false){
68
-        if (!static::$fields) static::$fields = new Map();
81
+    public static function merge(array $array, $merge_back=false) {
82
+        if (!static::$fields) {
83
+          static::$fields = new Map();
84
+        }
69 85
         static::$fields->merge($array, $merge_back);
70 86
     }
71 87
 
72
-    protected static function compact(){
73
-        if (!static::$fields) static::$fields = new Map();
88
+    protected static function compact() {
89
+        if (!static::$fields) {
90
+          static::$fields = new Map();
91
+        }
74 92
         static::$fields->compact();
75 93
     }
76 94
 
@@ -78,8 +96,10 @@  discard block
 block discarded – undo
78 96
         return static::$fields->find($path, $create, $operation);
79 97
     }
80 98
 
81
-    public function jsonSerialize(){
82
-      if (!static::$fields) static::$fields = new Map();
99
+    public function jsonSerialize() {
100
+      if (!static::$fields) {
101
+        static::$fields = new Map();
102
+      }
83 103
       return static::$fields->jsonSerialize();
84 104
     }
85 105
 
Please login to merge, or discard this patch.