Completed
Push — master ( 1ded02...260d88 )
by Stefano
03:45
created
classes/CSV.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -27,54 +27,54 @@  discard block
 block discarded – undo
27 27
             $format       = self::STANDARD,
28 28
             $savedheaders = false;
29 29
 
30
-  public static function open($file, $format=self::AUTO){
31
-    return new static($file,self::READ,$format);
30
+  public static function open($file, $format = self::AUTO) {
31
+    return new static($file, self::READ, $format);
32 32
   }
33 33
 
34
-  public static function create($file, $format=self::STANDARD){
35
-    return new static($file,self::WRITE, $format);
34
+  public static function create($file, $format = self::STANDARD) {
35
+    return new static($file, self::WRITE, $format);
36 36
   }
37 37
 
38
-  public static function fromSQL($sql, $format=self::AUTO){
38
+  public static function fromSQL($sql, $format = self::AUTO) {
39 39
     $csv = static::create(tempnam(sys_get_temp_dir(), 'CSVx'), $format);
40
-    SQL::each($sql,function($row) use (&$csv){
40
+    SQL::each($sql, function($row) use (&$csv){
41 41
       $csv->write($row);
42 42
     });
43 43
     return $csv;
44 44
   }
45 45
 
46
-  public static function fromTable($table, $format=self::AUTO){
46
+  public static function fromTable($table, $format = self::AUTO) {
47 47
     $csv = static::create(tempnam(sys_get_temp_dir(), 'CSVx'), $format);
48
-    foreach($table as $row){
48
+    foreach ($table as $row) {
49 49
       $csv->write($row);
50 50
     }
51 51
     return $csv;
52 52
   }
53 53
 
54
-  public function __construct($file, $mode=self::READ, $format=self::AUTO){
54
+  public function __construct($file, $mode = self::READ, $format = self::AUTO) {
55 55
     $this->mode = $mode;
56
-    $this->file = new \SplFileObject($file,'c+');
56
+    $this->file = new \SplFileObject($file, 'c+');
57 57
     if (!$this->file->valid()) throw new Exception("Error opening CSV file [$file]", 1);
58 58
     $this->file->setFlags(
59
-      \SplFileObject::READ_CSV |     // set file reading mode to csv
60
-      \SplFileObject::SKIP_EMPTY |   // ignore empty lines
59
+      \SplFileObject::READ_CSV | // set file reading mode to csv
60
+      \SplFileObject::SKIP_EMPTY | // ignore empty lines
61 61
       \SplFileObject::DROP_NEW_LINE  // drop new line from last column in record
62 62
     );
63
-    $this->format = ($format==self::AUTO ? $this->guessSeparator() : $format);
64
-    $this->file->setCsvControl($this->format,'"',"\\");
63
+    $this->format = ($format == self::AUTO ? $this->guessSeparator() : $format);
64
+    $this->file->setCsvControl($this->format, '"', "\\");
65 65
   }
66 66
 
67
-  private function guessSeparator($checkLines = 2){
67
+  private function guessSeparator($checkLines = 2) {
68 68
     if ($this->mode == self::WRITE) return self::STANDARD;
69
-    $delimiters = [",","\t",";"];
69
+    $delimiters = [",", "\t", ";"];
70 70
     $results = [];
71 71
     $this->file->rewind();
72 72
     while ($checkLines--) {
73 73
         $line = $this->file->fgets();
74
-        foreach ($delimiters as $delimiter){
74
+        foreach ($delimiters as $delimiter) {
75 75
             $fields = preg_split('/['.$delimiter.']/', $line);
76
-            if(count($fields) > 1){
77
-                if(empty($results[$delimiter])){
76
+            if (count($fields) > 1) {
77
+                if (empty($results[$delimiter])) {
78 78
                   $results[$delimiter] = 1;
79 79
                 } else {
80 80
                   $results[$delimiter]++;
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
     return $results[0];
88 88
   }
89 89
 
90
-  public function write($row){
90
+  public function write($row) {
91 91
     if ($this->mode != self::WRITE) return;
92
-    $row = (array)$row;
92
+    $row = (array) $row;
93 93
     if (false === $this->savedheaders) {
94 94
       $this->schema(array_keys($row));
95 95
     }
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     $this->file->fputcsv($row_t);
101 101
   }
102 102
 
103
-  public function read(){
103
+  public function read() {
104 104
     if ($this->mode != self::READ) return;
105
-    foreach($this->file as $row){
106
-      if ($row){
107
-        if(!$this->headers) {
105
+    foreach ($this->file as $row) {
106
+      if ($row) {
107
+        if (!$this->headers) {
108 108
           $this->headers = $row;
109 109
           continue;
110 110
         }
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
     return;
115 115
   }
116 116
 
117
-  public function each(callable $looper = null){
117
+  public function each(callable $looper = null) {
118 118
     if ($looper) {
119
-      foreach($this->read() as $row) $looper($row);
119
+      foreach ($this->read() as $row) $looper($row);
120 120
       return $this;
121 121
     } else {
122 122
       $results = [];
123
-      foreach($this->read() as $row) $results[] = $row;
123
+      foreach ($this->read() as $row) $results[] = $row;
124 124
       return $results;
125 125
     }
126 126
   }
127 127
 
128
-  public function convert($filename, $format=self::STANDARD){
128
+  public function convert($filename, $format = self::STANDARD) {
129 129
     if ($this->mode != self::READ) return;
130 130
     if ($format == self::AUTO) $format = self::STANDARD;
131 131
     $csv = CSV::create($filename, CSV::EXCEL);
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
     return $csv;
136 136
   }
137 137
 
138
-  public function flush(){
138
+  public function flush() {
139 139
     if ($this->mode == self::WRITE) {
140 140
       $this->file->fflush();
141 141
     }
142 142
   }
143 143
 
144
-  public function schema($schema=null){
145
-    if($schema){
146
-      $this->headers = array_values((array)$schema);
144
+  public function schema($schema = null) {
145
+    if ($schema) {
146
+      $this->headers = array_values((array) $schema);
147 147
       if ($this->mode == self::WRITE) {
148 148
         $this->savedheaders = true;
149
-        $this->template = array_combine($this->headers, array_pad([],count($this->headers),''));
149
+        $this->template = array_combine($this->headers, array_pad([], count($this->headers), ''));
150 150
         $this->file->fputcsv($this->headers);
151 151
       }
152 152
       return $this;
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
     }
156 156
   }
157 157
 
158
-  public function asString(){
158
+  public function asString() {
159 159
     $this->flush();
160 160
     return file_get_contents($this->file->getPathname());
161 161
   }
162 162
 
163
-  public function __toString(){
164
-    try { return $this->asString(); } catch(\Exception $e) { return ''; }
163
+  public function __toString() {
164
+    try { return $this->asString();} catch (\Exception $e) { return '';}
165 165
   }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Braces   +43 added lines, -29 removed lines patch added patch discarded remove patch
@@ -27,34 +27,36 @@  discard block
 block discarded – undo
27 27
             $format       = self::STANDARD,
28 28
             $savedheaders = false;
29 29
 
30
-  public static function open($file, $format=self::AUTO){
30
+  public static function open($file, $format=self::AUTO) {
31 31
     return new static($file,self::READ,$format);
32 32
   }
33 33
 
34
-  public static function create($file, $format=self::STANDARD){
34
+  public static function create($file, $format=self::STANDARD) {
35 35
     return new static($file,self::WRITE, $format);
36 36
   }
37 37
 
38
-  public static function fromSQL($sql, $format=self::AUTO){
38
+  public static function fromSQL($sql, $format=self::AUTO) {
39 39
     $csv = static::create(tempnam(sys_get_temp_dir(), 'CSVx'), $format);
40
-    SQL::each($sql,function($row) use (&$csv){
40
+    SQL::each($sql,function($row) use (&$csv) {
41 41
       $csv->write($row);
42 42
     });
43 43
     return $csv;
44 44
   }
45 45
 
46
-  public static function fromTable($table, $format=self::AUTO){
46
+  public static function fromTable($table, $format=self::AUTO) {
47 47
     $csv = static::create(tempnam(sys_get_temp_dir(), 'CSVx'), $format);
48
-    foreach($table as $row){
48
+    foreach($table as $row) {
49 49
       $csv->write($row);
50 50
     }
51 51
     return $csv;
52 52
   }
53 53
 
54
-  public function __construct($file, $mode=self::READ, $format=self::AUTO){
54
+  public function __construct($file, $mode=self::READ, $format=self::AUTO) {
55 55
     $this->mode = $mode;
56 56
     $this->file = new \SplFileObject($file,'c+');
57
-    if (!$this->file->valid()) throw new Exception("Error opening CSV file [$file]", 1);
57
+    if (!$this->file->valid()) {
58
+      throw new Exception("Error opening CSV file [$file]", 1);
59
+    }
58 60
     $this->file->setFlags(
59 61
       \SplFileObject::READ_CSV |     // set file reading mode to csv
60 62
       \SplFileObject::SKIP_EMPTY |   // ignore empty lines
@@ -64,17 +66,19 @@  discard block
 block discarded – undo
64 66
     $this->file->setCsvControl($this->format,'"',"\\");
65 67
   }
66 68
 
67
-  private function guessSeparator($checkLines = 2){
68
-    if ($this->mode == self::WRITE) return self::STANDARD;
69
+  private function guessSeparator($checkLines = 2) {
70
+    if ($this->mode == self::WRITE) {
71
+      return self::STANDARD;
72
+    }
69 73
     $delimiters = [",","\t",";"];
70 74
     $results = [];
71 75
     $this->file->rewind();
72 76
     while ($checkLines--) {
73 77
         $line = $this->file->fgets();
74
-        foreach ($delimiters as $delimiter){
78
+        foreach ($delimiters as $delimiter) {
75 79
             $fields = preg_split('/['.$delimiter.']/', $line);
76
-            if(count($fields) > 1){
77
-                if(empty($results[$delimiter])){
80
+            if(count($fields) > 1) {
81
+                if(empty($results[$delimiter])) {
78 82
                   $results[$delimiter] = 1;
79 83
                 } else {
80 84
                   $results[$delimiter]++;
@@ -87,23 +91,29 @@  discard block
 block discarded – undo
87 91
     return $results[0];
88 92
   }
89 93
 
90
-  public function write($row){
91
-    if ($this->mode != self::WRITE) return;
94
+  public function write($row) {
95
+    if ($this->mode != self::WRITE) {
96
+      return;
97
+    }
92 98
     $row = (array)$row;
93 99
     if (false === $this->savedheaders) {
94 100
       $this->schema(array_keys($row));
95 101
     }
96 102
     $row_t = $this->template;
97 103
     foreach ($this->headers as $key) {
98
-      if (isset($row[$key])) $row_t[$key] = $row[$key];
104
+      if (isset($row[$key])) {
105
+        $row_t[$key] = $row[$key];
106
+      }
99 107
     }
100 108
     $this->file->fputcsv($row_t);
101 109
   }
102 110
 
103
-  public function read(){
104
-    if ($this->mode != self::READ) return;
105
-    foreach($this->file as $row){
106
-      if ($row){
111
+  public function read() {
112
+    if ($this->mode != self::READ) {
113
+      return;
114
+    }
115
+    foreach($this->file as $row) {
116
+      if ($row) {
107 117
         if(!$this->headers) {
108 118
           $this->headers = $row;
109 119
           continue;
@@ -114,7 +124,7 @@  discard block
 block discarded – undo
114 124
     return;
115 125
   }
116 126
 
117
-  public function each(callable $looper = null){
127
+  public function each(callable $looper = null) {
118 128
     if ($looper) {
119 129
       foreach($this->read() as $row) $looper($row);
120 130
       return $this;
@@ -125,9 +135,13 @@  discard block
 block discarded – undo
125 135
     }
126 136
   }
127 137
 
128
-  public function convert($filename, $format=self::STANDARD){
129
-    if ($this->mode != self::READ) return;
130
-    if ($format == self::AUTO) $format = self::STANDARD;
138
+  public function convert($filename, $format=self::STANDARD) {
139
+    if ($this->mode != self::READ) {
140
+      return;
141
+    }
142
+    if ($format == self::AUTO) {
143
+      $format = self::STANDARD;
144
+    }
131 145
     $csv = CSV::create($filename, CSV::EXCEL);
132 146
     $this->each(function($row) use ($csv) {
133 147
       $csv->write($row);
@@ -135,14 +149,14 @@  discard block
 block discarded – undo
135 149
     return $csv;
136 150
   }
137 151
 
138
-  public function flush(){
152
+  public function flush() {
139 153
     if ($this->mode == self::WRITE) {
140 154
       $this->file->fflush();
141 155
     }
142 156
   }
143 157
 
144
-  public function schema($schema=null){
145
-    if($schema){
158
+  public function schema($schema=null) {
159
+    if($schema) {
146 160
       $this->headers = array_values((array)$schema);
147 161
       if ($this->mode == self::WRITE) {
148 162
         $this->savedheaders = true;
@@ -155,12 +169,12 @@  discard block
 block discarded – undo
155 169
     }
156 170
   }
157 171
 
158
-  public function asString(){
172
+  public function asString() {
159 173
     $this->flush();
160 174
     return file_get_contents($this->file->getPathname());
161 175
   }
162 176
 
163
-  public function __toString(){
177
+  public function __toString() {
164 178
     try { return $this->asString(); } catch(\Exception $e) { return ''; }
165 179
   }
166 180
 
Please login to merge, or discard this patch.
classes/Options.php 3 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -13,52 +13,52 @@
 block discarded – undo
13 13
 class Options extends Dictionary {
14 14
   protected static $fields = [];
15 15
 
16
-	/**
17
-	 * Load a PHP configuration file (script must return array)
18
-	 * @param  string $filepath The path of the PHP config file
19
-	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
20
-	 */
21
-	public static function loadPHP($filepath,$prefix_path=null){
22
-		ob_start();
23
-		$results = include($filepath);
24
-		ob_end_clean();
25
-		if($results) static::loadArray($results,$prefix_path);
26
-	}
16
+  /**
17
+   * Load a PHP configuration file (script must return array)
18
+   * @param  string $filepath The path of the PHP config file
19
+   * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
20
+   */
21
+  public static function loadPHP($filepath,$prefix_path=null){
22
+    ob_start();
23
+    $results = include($filepath);
24
+    ob_end_clean();
25
+    if($results) static::loadArray($results,$prefix_path);
26
+  }
27 27
 
28
-	/**
29
-	 * Load an INI configuration file
30
-	 * @param  string $filepath The path of the INI config file
31
-	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
32
-	 */
33
-	public static function loadINI($filepath,$prefix_path=null){
34
-		$results = parse_ini_file($filepath,true);
35
-		if($results) static::loadArray($results,$prefix_path);
36
-	}
28
+  /**
29
+   * Load an INI configuration file
30
+   * @param  string $filepath The path of the INI config file
31
+   * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
32
+   */
33
+  public static function loadINI($filepath,$prefix_path=null){
34
+    $results = parse_ini_file($filepath,true);
35
+    if($results) static::loadArray($results,$prefix_path);
36
+  }
37 37
 
38
-	/**
39
-	 * Load a JSON configuration file
40
-	 * @param  string $filepath The path of the JSON config file
41
-	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
42
-	 */
43
-	public static function loadJSON($filepath,$prefix_path=null){
44
-		$data = file_get_contents($filepath);
45
-		$results = $data?json_decode($data,true):[];
46
-		if($results) static::loadArray($results,$prefix_path);
47
-	}
38
+  /**
39
+   * Load a JSON configuration file
40
+   * @param  string $filepath The path of the JSON config file
41
+   * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
42
+   */
43
+  public static function loadJSON($filepath,$prefix_path=null){
44
+    $data = file_get_contents($filepath);
45
+    $results = $data?json_decode($data,true):[];
46
+    if($results) static::loadArray($results,$prefix_path);
47
+  }
48 48
 
49
-	/**
50
-	 * Load an array to the configuration
51
-	 * @param  array $array The array to load
52
-	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
53
-	 */
54
-	public static function loadArray(array $array,$prefix_path=null){
55
-		if (is_array($array)) {
56
-			if ($prefix_path){
57
-				static::set($prefix_path,$array);
58
-			} else {
59
-				static::merge($array);
60
-			}
61
-		}
62
-	}
49
+  /**
50
+   * Load an array to the configuration
51
+   * @param  array $array The array to load
52
+   * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
53
+   */
54
+  public static function loadArray(array $array,$prefix_path=null){
55
+    if (is_array($array)) {
56
+      if ($prefix_path){
57
+        static::set($prefix_path,$array);
58
+      } else {
59
+        static::merge($array);
60
+      }
61
+    }
62
+  }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 	 * @param  string $filepath The path of the PHP config file
19 19
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
20 20
 	 */
21
-	public static function loadPHP($filepath,$prefix_path=null){
21
+	public static function loadPHP($filepath, $prefix_path = null) {
22 22
 		ob_start();
23 23
 		$results = include($filepath);
24 24
 		ob_end_clean();
25
-		if($results) static::loadArray($results,$prefix_path);
25
+		if ($results) static::loadArray($results, $prefix_path);
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 * @param  string $filepath The path of the INI config file
31 31
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
32 32
 	 */
33
-	public static function loadINI($filepath,$prefix_path=null){
34
-		$results = parse_ini_file($filepath,true);
35
-		if($results) static::loadArray($results,$prefix_path);
33
+	public static function loadINI($filepath, $prefix_path = null) {
34
+		$results = parse_ini_file($filepath, true);
35
+		if ($results) static::loadArray($results, $prefix_path);
36 36
 	}
37 37
 
38 38
 	/**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	 * @param  string $filepath The path of the JSON config file
41 41
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
42 42
 	 */
43
-	public static function loadJSON($filepath,$prefix_path=null){
43
+	public static function loadJSON($filepath, $prefix_path = null) {
44 44
 		$data = file_get_contents($filepath);
45
-		$results = $data?json_decode($data,true):[];
46
-		if($results) static::loadArray($results,$prefix_path);
45
+		$results = $data ? json_decode($data, true) : [];
46
+		if ($results) static::loadArray($results, $prefix_path);
47 47
 	}
48 48
 
49 49
 	/**
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 * @param  array $array The array to load
52 52
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
53 53
 	 */
54
-	public static function loadArray(array $array,$prefix_path=null){
54
+	public static function loadArray(array $array, $prefix_path = null) {
55 55
 		if (is_array($array)) {
56
-			if ($prefix_path){
57
-				static::set($prefix_path,$array);
56
+			if ($prefix_path) {
57
+				static::set($prefix_path, $array);
58 58
 			} else {
59 59
 				static::merge($array);
60 60
 			}
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,11 +18,13 @@  discard block
 block discarded – undo
18 18
 	 * @param  string $filepath The path of the PHP config file
19 19
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
20 20
 	 */
21
-	public static function loadPHP($filepath,$prefix_path=null){
21
+	public static function loadPHP($filepath,$prefix_path=null) {
22 22
 		ob_start();
23 23
 		$results = include($filepath);
24 24
 		ob_end_clean();
25
-		if($results) static::loadArray($results,$prefix_path);
25
+		if($results) {
26
+		  static::loadArray($results,$prefix_path);
27
+		}
26 28
 	}
27 29
 
28 30
 	/**
@@ -30,9 +32,11 @@  discard block
 block discarded – undo
30 32
 	 * @param  string $filepath The path of the INI config file
31 33
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
32 34
 	 */
33
-	public static function loadINI($filepath,$prefix_path=null){
35
+	public static function loadINI($filepath,$prefix_path=null) {
34 36
 		$results = parse_ini_file($filepath,true);
35
-		if($results) static::loadArray($results,$prefix_path);
37
+		if($results) {
38
+		  static::loadArray($results,$prefix_path);
39
+		}
36 40
 	}
37 41
 
38 42
 	/**
@@ -40,10 +44,12 @@  discard block
 block discarded – undo
40 44
 	 * @param  string $filepath The path of the JSON config file
41 45
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
42 46
 	 */
43
-	public static function loadJSON($filepath,$prefix_path=null){
47
+	public static function loadJSON($filepath,$prefix_path=null) {
44 48
 		$data = file_get_contents($filepath);
45 49
 		$results = $data?json_decode($data,true):[];
46
-		if($results) static::loadArray($results,$prefix_path);
50
+		if($results) {
51
+		  static::loadArray($results,$prefix_path);
52
+		}
47 53
 	}
48 54
 
49 55
 	/**
@@ -51,9 +57,9 @@  discard block
 block discarded – undo
51 57
 	 * @param  array $array The array to load
52 58
 	 * @param  string $prefix_path You can insert/update the loaded array to a specific key path, if omitted it will be merged with the whole dictionary
53 59
 	 */
54
-	public static function loadArray(array $array,$prefix_path=null){
60
+	public static function loadArray(array $array,$prefix_path=null) {
55 61
 		if (is_array($array)) {
56
-			if ($prefix_path){
62
+			if ($prefix_path) {
57 63
 				static::set($prefix_path,$array);
58 64
 			} else {
59 65
 				static::merge($array);
Please login to merge, or discard this patch.
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/Text.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 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){
31
-     if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t);
32
-     for(  // Init
33
-           $r = $ox = $x = false;
34
-           // While
35
-           false !== ($x = $y = strpos($t,'{{',$x));
36
-           // Do
37
-           $r .= substr($t, $ox, $x-$ox),
38
-           $c  = substr($t, $x += 2, $l = ( $y = strpos($t,'}}', $x) ) - $x),
39
-           $ox = $x += $l + 2,
40
-           $r .= Object::fetch(trim($c),$v)?:''
41
-     );
42
-     return $r===false ? $t : $r.substr($t,$ox);
43
-   }
30
+    public static function render($t,$v=null){
31
+      if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t);
32
+      for(  // Init
33
+            $r = $ox = $x = false;
34
+            // While
35
+            false !== ($x = $y = strpos($t,'{{',$x));
36
+            // Do
37
+            $r .= substr($t, $ox, $x-$ox),
38
+            $c  = substr($t, $x += 2, $l = ( $y = strpos($t,'}}', $x) ) - $x),
39
+            $ox = $x += $l + 2,
40
+            $r .= Object::fetch(trim($c),$v)?:''
41
+      );
42
+      return $r===false ? $t : $r.substr($t,$ox);
43
+    }
44 44
 
45 45
 } /* End of class */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 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){
31
-     if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t);
32
-     for(  // Init
30
+   public static function render($t, $v = null) {
31
+     if (empty($v)) return preg_replace('/{{[^}]+}}/', '', $t);
32
+     for (  // Init
33 33
            $r = $ox = $x = false;
34 34
            // While
35
-           false !== ($x = $y = strpos($t,'{{',$x));
35
+           false !== ($x = $y = strpos($t, '{{', $x));
36 36
            // Do
37
-           $r .= substr($t, $ox, $x-$ox),
38
-           $c  = substr($t, $x += 2, $l = ( $y = strpos($t,'}}', $x) ) - $x),
37
+           $r .= substr($t, $ox, $x - $ox),
38
+           $c  = substr($t, $x += 2, $l = ($y = strpos($t, '}}', $x)) - $x),
39 39
            $ox = $x += $l + 2,
40
-           $r .= Object::fetch(trim($c),$v)?:''
40
+           $r .= Object::fetch(trim($c), $v) ?: ''
41 41
      );
42
-     return $r===false ? $t : $r.substr($t,$ox);
42
+     return $r === false ? $t : $r.substr($t, $ox);
43 43
    }
44 44
 
45 45
 } /* End of class */
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,10 @@
 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){
31
-     if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t);
30
+   public static function render($t,$v=null) {
31
+     if (empty($v)) {
32
+       return preg_replace('/{{[^}]+}}/','',$t);
33
+     }
32 34
      for(  // Init
33 35
            $r = $ox = $x = false;
34 36
            // While
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.