Completed
Branch master (1901f0)
by Stefano
02:53
created
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/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.