Completed
Push — master ( 1f9686...114e61 )
by Stefano
03:01
created
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/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.
classes/Hash.php 5 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -110,6 +110,9 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 	}
112 112
 
113
+  /**
114
+   * @param string $key
115
+   */
113 116
   public static function murmur($key, $seed = 0, $as_integer=false) {
114 117
 		$key = (string) $key;
115 118
 		$klen = strlen($key);
@@ -161,6 +164,11 @@  discard block
 block discarded – undo
161 164
     return strtr(base64_encode(static::random_bytes($bytes)),'+/=','-_');
162 165
   }
163 166
 
167
+  /**
168
+   * @param integer $bytes
169
+   *
170
+   * @return string
171
+   */
164 172
   public static function random_bytes($bytes){
165 173
     static $randf = null;
166 174
     if (function_exists('random_bytes')) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -157,11 +157,11 @@
 block discarded – undo
157 157
 		return $as_integer ? $h1 : base_convert($h1 ,10, 32);
158 158
 	}
159 159
 
160
-  public static function random($bytes=9){
160
+  public static function random($bytes=9) {
161 161
     return strtr(base64_encode(static::random_bytes($bytes)),'+/=','-_');
162 162
   }
163 163
 
164
-  public static function random_bytes($bytes){
164
+  public static function random_bytes($bytes) {
165 165
     static $randf = null;
166 166
     if (function_exists('random_bytes')) {
167 167
       return \random_bytes($bytes);
Please login to merge, or discard this patch.
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -11,104 +11,104 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 class Hash {
14
-	use Module;
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 $method == 'murmur' ? static::murmur(serialize($payload)) : hash($method, serialize($payload));
24
-	}
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
-	}
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() {
14
+  use Module;
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 $method == 'murmur' ? static::murmur(serialize($payload)) : hash($method, serialize($payload));
24
+  }
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
+  }
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 45
     // Merge PHP provided algos with ours (murmur)
46
-		return array_merge(hash_algos(), ['murmur','murmurhash3']);
47
-	}
48
-
49
-	/**
50
-	 * Check if an alghoritm is registered in current PHP
51
-	 *
52
-	 * @method can
53
-	 *
54
-	 * @param  string $algo The hashing algorithm name
55
-	 *
56
-	 * @return bool
57
-	 */
58
-	public static function can($algo) {
46
+    return array_merge(hash_algos(), ['murmur','murmurhash3']);
47
+  }
48
+
49
+  /**
50
+   * Check if an alghoritm is registered in current PHP
51
+   *
52
+   * @method can
53
+   *
54
+   * @param  string $algo The hashing algorithm name
55
+   *
56
+   * @return bool
57
+   */
58
+  public static function can($algo) {
59 59
     // Faster than : in_array(explode(',',implode(',',static::methods())))
60
-		return strpos(implode(',',static::methods()).',', "$algo,") !== false;
61
-	}
62
-
63
-	/**
64
-	 * Static magic for creating hashes with a specified algorithm.
65
-	 *
66
-	 * See [hash-algos](http://php.net/manual/it/function.hash-algos.php) for a list of algorithms
67
-	 */
68
-	public static function __callStatic($method, $params) {
69
-		return self::make(current($params), $method);
70
-	}
71
-
72
-	public static function uuid($type = 4, $namespace = '', $name = '') {
73
-		switch ($type) {
74
-		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
75
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
76
-				return false;
77
-			}
78
-
79
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
80
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
81
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
82
-			}
83
-
84
-			$hash = md5($nstr . $name);
85
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
86
-				substr($hash, 0, 8), substr($hash, 8, 4),
87
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
88
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
89
-				substr($hash, 20, 12));
90
-		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
91
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
92
-				return false;
93
-			}
94
-
95
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
96
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
97
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
98
-			}
99
-
100
-			$hash = sha1($nstr . $name);
101
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
102
-				substr($hash, 0, 8), substr($hash, 8, 4),
103
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
104
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
105
-				substr($hash, 20, 12));
106
-		default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
107
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
108
-				mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
109
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
110
-		}
111
-	}
60
+    return strpos(implode(',',static::methods()).',', "$algo,") !== false;
61
+  }
62
+
63
+  /**
64
+   * Static magic for creating hashes with a specified algorithm.
65
+   *
66
+   * See [hash-algos](http://php.net/manual/it/function.hash-algos.php) for a list of algorithms
67
+   */
68
+  public static function __callStatic($method, $params) {
69
+    return self::make(current($params), $method);
70
+  }
71
+
72
+  public static function uuid($type = 4, $namespace = '', $name = '') {
73
+    switch ($type) {
74
+    case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
75
+        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
76
+        return false;
77
+      }
78
+
79
+      $nhex = str_replace(array('-', '{', '}'), '', $namespace);
80
+      $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
81
+        $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
82
+      }
83
+
84
+      $hash = md5($nstr . $name);
85
+      return sprintf('%08s-%04s-%04x-%04x-%12s',
86
+        substr($hash, 0, 8), substr($hash, 8, 4),
87
+        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
88
+        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
89
+        substr($hash, 20, 12));
90
+    case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
91
+        '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
92
+        return false;
93
+      }
94
+
95
+      $nhex = str_replace(array('-', '{', '}'), '', $namespace);
96
+      $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
97
+        $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
98
+      }
99
+
100
+      $hash = sha1($nstr . $name);
101
+      return sprintf('%08s-%04s-%04x-%04x-%12s',
102
+        substr($hash, 0, 8), substr($hash, 8, 4),
103
+        (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
104
+        (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
105
+        substr($hash, 20, 12));
106
+    default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
107
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
108
+        mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
109
+        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
110
+    }
111
+  }
112 112
 
113 113
   public static function murmur($key, $seed = 0, $as_integer=false) {
114 114
     $key  = array_values(unpack('C*',(string) $key));
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
     $h1  = (((($h1 & 0xffff) * 0xc2b2ae35) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000)) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
146 146
     $h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
147 147
 
148
-		return $as_integer ? $h1 : base_convert($h1 ,10, 32);
149
-	}
148
+    return $as_integer ? $h1 : base_convert($h1 ,10, 32);
149
+  }
150 150
 
151 151
   public static function random($bytes=9){
152 152
     return strtr(base64_encode(static::random_bytes($bytes)),'+/=','-_');
Please login to merge, or discard this patch.
Switch Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -71,42 +71,42 @@
 block discarded – undo
71 71
 
72 72
 	public static function uuid($type = 4, $namespace = '', $name = '') {
73 73
 		switch ($type) {
74
-		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
75
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
76
-				return false;
77
-			}
78
-
79
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
80
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
81
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
82
-			}
83
-
84
-			$hash = md5($nstr . $name);
85
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
86
-				substr($hash, 0, 8), substr($hash, 8, 4),
87
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
88
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
89
-				substr($hash, 20, 12));
90
-		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
91
-				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
92
-				return false;
93
-			}
94
-
95
-			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
96
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
97
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
98
-			}
99
-
100
-			$hash = sha1($nstr . $name);
101
-			return sprintf('%08s-%04s-%04x-%04x-%12s',
102
-				substr($hash, 0, 8), substr($hash, 8, 4),
103
-				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
104
-				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
105
-				substr($hash, 20, 12));
106
-		default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
107
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
108
-				mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
109
-				mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
74
+		  case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
75
+				  '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
76
+				  return false;
77
+			  }
78
+
79
+			  $nhex = str_replace(array('-', '{', '}'), '', $namespace);
80
+			  $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
81
+				  $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
82
+			  }
83
+
84
+			  $hash = md5($nstr . $name);
85
+			  return sprintf('%08s-%04s-%04x-%04x-%12s',
86
+				  substr($hash, 0, 8), substr($hash, 8, 4),
87
+				  (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
88
+				  (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
89
+				  substr($hash, 20, 12));
90
+		  case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
91
+				  '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
92
+				  return false;
93
+			  }
94
+
95
+			  $nhex = str_replace(array('-', '{', '}'), '', $namespace);
96
+			  $nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
97
+				  $nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
98
+			  }
99
+
100
+			  $hash = sha1($nstr . $name);
101
+			  return sprintf('%08s-%04s-%04x-%04x-%12s',
102
+				  substr($hash, 0, 8), substr($hash, 8, 4),
103
+				  (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
104
+				  (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
105
+				  substr($hash, 20, 12));
106
+		  default:case 4:return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
107
+				  mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
108
+				  mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
109
+				  mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
110 110
 		}
111 111
 	}
112 112
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function methods() {
45 45
     // Merge PHP provided algos with ours (murmur)
46
-		return array_merge(hash_algos(), ['murmur','murmurhash3']);
46
+		return array_merge(hash_algos(), ['murmur', 'murmurhash3']);
47 47
 	}
48 48
 
49 49
 	/**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public static function can($algo) {
59 59
     // Faster than : in_array(explode(',',implode(',',static::methods())))
60
-		return strpos(implode(',',static::methods()).',', "$algo,") !== false;
60
+		return strpos(implode(',', static::methods()).',', "$algo,") !== false;
61 61
 	}
62 62
 
63 63
 	/**
@@ -71,33 +71,33 @@  discard block
 block discarded – undo
71 71
 
72 72
 	public static function uuid($type = 4, $namespace = '', $name = '') {
73 73
 		switch ($type) {
74
-		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
74
+		case 3:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
75 75
 				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
76 76
 				return false;
77 77
 			}
78 78
 
79 79
 			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
80
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
81
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
80
+			$nstr = '';for ($i = 0;$i < strlen($nhex);$i += 2) {
81
+				$nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
82 82
 			}
83 83
 
84
-			$hash = md5($nstr . $name);
84
+			$hash = md5($nstr.$name);
85 85
 			return sprintf('%08s-%04s-%04x-%04x-%12s',
86 86
 				substr($hash, 0, 8), substr($hash, 8, 4),
87 87
 				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
88 88
 				(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
89 89
 				substr($hash, 20, 12));
90
-		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' .
90
+		case 5:if (preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?'.
91 91
 				'[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/Si', $namespace) !== 1) {
92 92
 				return false;
93 93
 			}
94 94
 
95 95
 			$nhex = str_replace(array('-', '{', '}'), '', $namespace);
96
-			$nstr = '';for ($i = 0; $i < strlen($nhex); $i += 2) {
97
-				$nstr .= chr(hexdec($nhex[$i] . $nhex[$i + 1]));
96
+			$nstr = '';for ($i = 0;$i < strlen($nhex);$i += 2) {
97
+				$nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1]));
98 98
 			}
99 99
 
100
-			$hash = sha1($nstr . $name);
100
+			$hash = sha1($nstr.$name);
101 101
 			return sprintf('%08s-%04s-%04x-%04x-%12s',
102 102
 				substr($hash, 0, 8), substr($hash, 8, 4),
103 103
 				(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 	}
112 112
 
113
-  public static function murmur($key, $seed = 0, $as_integer=false) {
114
-    $key  = array_values(unpack('C*',(string) $key));
113
+  public static function murmur($key, $seed = 0, $as_integer = false) {
114
+    $key  = array_values(unpack('C*', (string) $key));
115 115
     $klen = count($key);
116
-    $h1   = (int)$seed;
117
-    for ($i=0,$bytes=$klen-($remainder=$klen&3) ; $i<$bytes ; ) {
116
+    $h1   = (int) $seed;
117
+    for ($i = 0, $bytes = $klen - ($remainder = $klen & 3);$i < $bytes;) {
118 118
       $k1 = $key[$i]
119 119
         | ($key[++$i] << 8)
120 120
         | ($key[++$i] << 16)
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
     $h1  = (((($h1 & 0xffff) * 0xc2b2ae35) + ((((($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000)) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
146 146
     $h1 ^= ($h1 >= 0 ? $h1 >> 16 : (($h1 & 0x7fffffff) >> 16) | 0x8000);
147 147
 
148
-		return $as_integer ? $h1 : base_convert($h1 ,10, 32);
148
+		return $as_integer ? $h1 : base_convert($h1, 10, 32);
149 149
 	}
150 150
 
151
-  public static function random($bytes=9){
152
-    return strtr(base64_encode(static::random_bytes($bytes)),'+/=','-_');
151
+  public static function random($bytes = 9) {
152
+    return strtr(base64_encode(static::random_bytes($bytes)), '+/=', '-_');
153 153
   }
154 154
 
155
-  public static function random_bytes($bytes){
155
+  public static function random_bytes($bytes) {
156 156
     static $randf = null;
157 157
     if (function_exists('random_bytes')) {
158 158
       return \random_bytes($bytes);
Please login to merge, or discard this patch.
classes/Email/Proxy.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@
 block discarded – undo
22 22
 
23 23
   public function onSend(Envelope $envelope){
24 24
     return array_reduce( (array) \Event::trigger($this->listener, $envelope), function($carry, $item) {
25
-    	 if (is_bool($item)) $carry[] = $item;
26
-    	 return $carry;
25
+        if (is_bool($item)) $carry[] = $item;
26
+        return $carry;
27 27
     }, []);
28 28
   }
29 29
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@
 block discarded – undo
16 16
 
17 17
   protected $listener = 'core.email.proxy.send';
18 18
 
19
-  public function onInit($options){
19
+  public function onInit($options) {
20 20
     if (!empty($options['hook'])) $this->listener = $options['hook'];
21 21
   }
22 22
 
23
-  public function onSend(Envelope $envelope){
24
-    return array_reduce( (array) \Event::trigger($this->listener, $envelope), function($carry, $item) {
23
+  public function onSend(Envelope $envelope) {
24
+    return array_reduce((array) \Event::trigger($this->listener, $envelope), function($carry, $item) {
25 25
     	 if (is_bool($item)) $carry[] = $item;
26 26
     	 return $carry;
27 27
     }, []);
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,13 +16,17 @@
 block discarded – undo
16 16
 
17 17
   protected $listener = 'core.email.proxy.send';
18 18
 
19
-  public function onInit($options){
20
-    if (!empty($options['hook'])) $this->listener = $options['hook'];
19
+  public function onInit($options) {
20
+    if (!empty($options['hook'])) {
21
+      $this->listener = $options['hook'];
22
+    }
21 23
   }
22 24
 
23
-  public function onSend(Envelope $envelope){
25
+  public function onSend(Envelope $envelope) {
24 26
     return array_reduce( (array) \Event::trigger($this->listener, $envelope), function($carry, $item) {
25
-    	 if (is_bool($item)) $carry[] = $item;
27
+    	 if (is_bool($item)) {
28
+    	   $carry[] = $item;
29
+    	 }
26 30
     	 return $carry;
27 31
     }, []);
28 32
   }
Please login to merge, or discard this patch.
classes/Map.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      * @param  mixed $default (optional) The default value. If is a callable it will executed and the return value will be used.
30 30
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
31 31
      */
32
-    public function get($key, $default=null){
33
-        if (null !== ($ptr =& $this->find($key,false))){
32
+    public function get($key, $default = null) {
33
+        if (null !== ($ptr = & $this->find($key, false))) {
34 34
             return $ptr;
35 35
         } else {
36
-            if ($default !== null){
36
+            if ($default !== null) {
37 37
                 return $this->set($key, is_callable($default) ? call_user_func($default) : $default);
38 38
             } else {
39 39
                 return null;
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
      * @param  mixed $value (optional) The value. If is a callable it will executed and the return value will be used.
48 48
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
49 49
      */
50
-    public function set($key, $value=null){
50
+    public function set($key, $value = null) {
51 51
         if (is_array($key)) {
52 52
             return $this->merge($key);
53 53
         } else {
54
-            $ptr =& $this->find($key, true);
54
+            $ptr = & $this->find($key, true);
55 55
             return $ptr = $value;
56 56
         }
57 57
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param  string $key The key path in dot notation
62 62
      * @param  boolean $compact (optional) Compact map removing empty paths.
63 63
      */
64
-    public function delete($key, $compact=true){
64
+    public function delete($key, $compact = true) {
65 65
         $this->set($key, null);
66 66
         if ($compact) $this->compact();
67 67
     }
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
      * @param  string $key The key path in dot notation
72 72
      * @return boolean
73 73
      */
74
-    public function exists($key){
74
+    public function exists($key) {
75 75
         return null !== $this->find($key, false);
76 76
     }
77 77
 
78 78
     /**
79 79
      * Clear all key path in map.
80 80
      */
81
-    public function clear(){
81
+    public function clear() {
82 82
         $this->fields = [];
83 83
     }
84 84
 
85
-    public function __construct($fields=null){
85
+    public function __construct($fields = null) {
86 86
         $this->load($fields);
87 87
     }
88 88
 
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      * Load an associative array/object as the map source.
91 91
      * @param  string $fields The array to merge
92 92
      */
93
-    public function load($fields){
94
-        if ($fields) $this->fields = (array)$fields;
93
+    public function load($fields) {
94
+        if ($fields) $this->fields = (array) $fields;
95 95
     }
96 96
 
97 97
     /**
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
      * @param  array   $array The array to merge
100 100
      * @param  boolean $merge_back If `true` merge the map over the $array, if `false` (default) the reverse.
101 101
      */
102
-    public function merge($array, $merge_back=false){
102
+    public function merge($array, $merge_back = false) {
103 103
         $this->fields = $merge_back
104
-            ? array_replace_recursive((array)$array, $this->fields)
105
-            : array_replace_recursive($this->fields, (array)$array);
104
+            ? array_replace_recursive((array) $array, $this->fields)
105
+            : array_replace_recursive($this->fields, (array) $array);
106 106
     }
107 107
 
108 108
     /**
109 109
      * Compact map removing empty paths
110 110
      */
111 111
 
112
-    public function compact(){
112
+    public function compact() {
113 113
 
114 114
         $array_filter_rec = function($input, $callback = null) use (&$array_filter_rec) {
115 115
             foreach ($input as &$value) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             return array_filter($input, $callback);
121 121
         };
122 122
 
123
-        $this->fields = $array_filter_rec($this->fields,function($a){ return $a !== null; });
123
+        $this->fields = $array_filter_rec($this->fields, function($a) { return $a !== null;});
124 124
     }
125 125
 
126 126
     /**
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
      * @param  callable  If passed this callback will be applied to the founded value.
131 131
      * @return mixed The founded value.
132 132
      */
133
-    public function & find($path, $create=false, callable $operation=null) {
134
-        $create ? $value =& $this->fields : $value = $this->fields;
135
-        foreach (explode('.',$path) as $tok) if ($create || isset($value[$tok])) {
136
-          $value =& $value[$tok];
133
+    public function & find($path, $create = false, callable $operation = null) {
134
+        $create ? $value = & $this->fields : $value = $this->fields;
135
+        foreach (explode('.', $path) as $tok) if ($create || isset($value[$tok])) {
136
+          $value = & $value[$tok];
137 137
         } else {
138
-          $value = $create ? $value :  null;  break;
138
+          $value = $create ? $value : null;break;
139 139
         }
140
-        if ( is_callable($operation) ) $operation($value);
140
+        if (is_callable($operation)) $operation($value);
141 141
         return $value;
142 142
     }
143 143
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @return string        The json object
150 150
      */
151
-    public function jsonSerialize(){
151
+    public function jsonSerialize() {
152 152
       return $this->fields;
153 153
     }
154 154
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      * @param  mixed $default (optional) The default value. If is a callable it will executed and the return value will be used.
30 30
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
31 31
      */
32
-    public function get($key, $default=null){
33
-        if (null !== ($ptr =& $this->find($key,false))){
32
+    public function get($key, $default=null) {
33
+        if (null !== ($ptr =& $this->find($key,false))) {
34 34
             return $ptr;
35 35
         } else {
36
-            if ($default !== null){
36
+            if ($default !== null) {
37 37
                 return $this->set($key, is_callable($default) ? call_user_func($default) : $default);
38 38
             } else {
39 39
                 return null;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param  mixed $value (optional) The value. If is a callable it will executed and the return value will be used.
48 48
      * @return mixed The value of the key or the default (resolved) value if the key not existed.
49 49
      */
50
-    public function set($key, $value=null){
50
+    public function set($key, $value=null) {
51 51
         if (is_array($key)) {
52 52
             return $this->merge($key);
53 53
         } else {
@@ -61,9 +61,11 @@  discard block
 block discarded – undo
61 61
      * @param  string $key The key path in dot notation
62 62
      * @param  boolean $compact (optional) Compact map removing empty paths.
63 63
      */
64
-    public function delete($key, $compact=true){
64
+    public function delete($key, $compact=true) {
65 65
         $this->set($key, null);
66
-        if ($compact) $this->compact();
66
+        if ($compact) {
67
+          $this->compact();
68
+        }
67 69
     }
68 70
 
69 71
     /**
@@ -71,18 +73,18 @@  discard block
 block discarded – undo
71 73
      * @param  string $key The key path in dot notation
72 74
      * @return boolean
73 75
      */
74
-    public function exists($key){
76
+    public function exists($key) {
75 77
         return null !== $this->find($key, false);
76 78
     }
77 79
 
78 80
     /**
79 81
      * Clear all key path in map.
80 82
      */
81
-    public function clear(){
83
+    public function clear() {
82 84
         $this->fields = [];
83 85
     }
84 86
 
85
-    public function __construct($fields=null){
87
+    public function __construct($fields=null) {
86 88
         $this->load($fields);
87 89
     }
88 90
 
@@ -90,8 +92,10 @@  discard block
 block discarded – undo
90 92
      * Load an associative array/object as the map source.
91 93
      * @param  string $fields The array to merge
92 94
      */
93
-    public function load($fields){
94
-        if ($fields) $this->fields = (array)$fields;
95
+    public function load($fields) {
96
+        if ($fields) {
97
+          $this->fields = (array)$fields;
98
+        }
95 99
     }
96 100
 
97 101
     /**
@@ -99,7 +103,7 @@  discard block
 block discarded – undo
99 103
      * @param  array   $array The array to merge
100 104
      * @param  boolean $merge_back If `true` merge the map over the $array, if `false` (default) the reverse.
101 105
      */
102
-    public function merge($array, $merge_back=false){
106
+    public function merge($array, $merge_back=false) {
103 107
         $this->fields = $merge_back
104 108
             ? array_replace_recursive((array)$array, $this->fields)
105 109
             : array_replace_recursive($this->fields, (array)$array);
@@ -109,7 +113,7 @@  discard block
 block discarded – undo
109 113
      * Compact map removing empty paths
110 114
      */
111 115
 
112
-    public function compact(){
116
+    public function compact() {
113 117
 
114 118
         $array_filter_rec = function($input, $callback = null) use (&$array_filter_rec) {
115 119
             foreach ($input as &$value) {
@@ -137,7 +141,9 @@  discard block
 block discarded – undo
137 141
         } else {
138 142
           $value = $create ? $value :  null;  break;
139 143
         }
140
-        if ( is_callable($operation) ) $operation($value);
144
+        if ( is_callable($operation) ) {
145
+          $operation($value);
146
+        }
141 147
         return $value;
142 148
     }
143 149
 
@@ -148,7 +154,7 @@  discard block
 block discarded – undo
148 154
      *
149 155
      * @return string        The json object
150 156
      */
151
-    public function jsonSerialize(){
157
+    public function jsonSerialize() {
152 158
       return $this->fields;
153 159
     }
154 160
 
Please login to merge, or discard this patch.