Test Setup Failed
Push — master ( ba2f64...373408 )
by Php Easy Api
04:25
created
src/resta/Router/RouteProvider.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
     private function getCallBindController()
40 40
     {
41 41
         //we finally process the method of the class invoked by the user as a process and prepare it for the response
42
-        return app()->resolve(RouteWatch::class)->watch(function(){
42
+        return app()->resolve(RouteWatch::class)->watch(function() {
43 43
 
44 44
             // if the method in the instance object exists,
45 45
             // this method is executed to produce the output.
46
-            if(method_exists($this->app['instanceController'],$this->app['method'])){
47
-                return $this->app['di']($this->app['instanceController'],$this->app['method']);
46
+            if (method_exists($this->app['instanceController'], $this->app['method'])) {
47
+                return $this->app['di']($this->app['instanceController'], $this->app['method']);
48 48
             }
49 49
 
50 50
             //throw exception as unsuccessful
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function handle()
64 64
     {
65
-        return $this->app->resolve(RoutePolicy::class)->gate(function(){
65
+        return $this->app->resolve(RoutePolicy::class)->gate(function() {
66 66
 
67
-            $this->app->register('routerResult',$this->callController());
67
+            $this->app->register('routerResult', $this->callController());
68 68
 
69 69
             //we call our services as controller
70 70
             return $this->app['routerResult'];
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
         $namespace = $this->getControllerNamespace();
83 83
 
84 84
         //utils make bind via dependency injection named as service container
85
-        $this->app->register('serviceConf',$this->app['fileSystem']->callFile(StaticPathModel::getServiceConf()));
86
-        $this->app->register('instanceController',$this->app->resolve($namespace));
85
+        $this->app->register('serviceConf', $this->app['fileSystem']->callFile(StaticPathModel::getServiceConf()));
86
+        $this->app->register('instanceController', $this->app->resolve($namespace));
87 87
     }
88 88
 
89 89
     /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
         // based on the serviceConf variable,
102 102
         // we are doing parameter bindings in the method context in the routeParameters array key.
103
-        $this->app->register('serviceConf','routeParameters',[$method=>$parameters]);
103
+        $this->app->register('serviceConf', 'routeParameters', [$method=>$parameters]);
104 104
 
105 105
     }
106 106
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function setMethodNameViaDefine($methodName)
114 114
     {
115
-        define('methodName',strtolower($methodName));
115
+        define('methodName', strtolower($methodName));
116 116
     }
117 117
 
118 118
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $fromRoutes = Route::getRouteResolve();
144 144
         $method = $fromRoutes['method'] ?? $method;
145 145
 
146
-        $this->app->register('method',$method);
146
+        $this->app->register('method', $method);
147 147
         $this->app->register('routeParameters', $this->routeParametersAssign($this->resolveMethod($method)));
148 148
 
149 149
     }
Please login to merge, or discard this patch.
src/resta/Router/RoutePolicy.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
     {
17 17
         $di = $this->app['di'];
18 18
 
19
-        if(!method_exists(policy(),Route::getRouteControllerMethod())){
19
+        if (!method_exists(policy(), Route::getRouteControllerMethod())) {
20 20
             $directly = true;
21 21
         }
22 22
 
23
-        if(isset($directly) || $di(policy(),Route::getRouteControllerMethod())){
23
+        if (isset($directly) || $di(policy(), Route::getRouteControllerMethod())) {
24 24
             return call_user_func($callback);
25 25
         }
26 26
 
Please login to merge, or discard this patch.
src/resta/Support/Generator/Generator.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@
 block discarded – undo
71 71
                 if(!isset($implements)){
72 72
                     $content = '<?php'.$this->fileSystem->get($this->getEval('createClassExtend'));
73 73
                     eval("?>$content");
74
-                }
75
-                else{
74
+                } else{
76 75
                     $content = '<?php'.$this->fileSystem->get($this->getEval('createClassExtendWithImplements'));
77 76
                     eval("?>$content");
78 77
                 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @throws FileNotFoundException
16 16
      */
17
-    public function createClass($replacement=array())
17
+    public function createClass($replacement = array())
18 18
     {
19
-        if(file_exists($this->path)){
19
+        if (file_exists($this->path)) {
20 20
             $content = $this->fileSystem->get($this->getStubFile());
21 21
             $this->loaded['createClass'] = true;
22 22
 
23
-            if($this->fileSystem->put($this->file,$content)!==FALSE){
24
-                $this->replaceFileContent($replacement,$this->file);
23
+            if ($this->fileSystem->put($this->file, $content)!==FALSE) {
24
+                $this->replaceFileContent($replacement, $this->file);
25 25
             }
26 26
         }
27 27
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @throws FileNotFoundException
37 37
      */
38
-    public function createClassDocument($documents=array())
38
+    public function createClassDocument($documents = array())
39 39
     {
40
-        if(isset($this->loaded['createClass']) && count($documents)){
40
+        if (isset($this->loaded['createClass']) && count($documents)) {
41 41
             $content = '<?php'.$this->fileSystem->get($this->getEval('createClassDocument'));
42 42
             eval("?>$content");
43 43
         }
@@ -53,26 +53,26 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function createClassExtend($namespace, $alias)
55 55
     {
56
-        if(!is_null($namespace) && !is_null($alias) && !preg_match('@extends@',$this->getClassString())){
57
-            if(preg_match('@class\s(.*?).*@',$this->getClassString(),$class)){
58
-                $statements = explode(' ',$class[0]);
56
+        if (!is_null($namespace) && !is_null($alias) && !preg_match('@extends@', $this->getClassString())) {
57
+            if (preg_match('@class\s(.*?).*@', $this->getClassString(), $class)) {
58
+                $statements = explode(' ', $class[0]);
59 59
                 $className = $statements[1];
60 60
 
61
-                if(count($statements)>2){
62
-                    $implements = implode(' ',array_slice($statements,2));
61
+                if (count($statements)>2) {
62
+                    $implements = implode(' ', array_slice($statements, 2));
63 63
                 }
64 64
             }
65 65
 
66
-            if(isset($className)){
66
+            if (isset($className)) {
67 67
                 $this->createClassUse([
68 68
                     $namespace
69 69
                 ]);
70 70
 
71
-                if(!isset($implements)){
71
+                if (!isset($implements)) {
72 72
                     $content = '<?php'.$this->fileSystem->get($this->getEval('createClassExtend'));
73 73
                     eval("?>$content");
74 74
                 }
75
-                else{
75
+                else {
76 76
                     $content = '<?php'.$this->fileSystem->get($this->getEval('createClassExtendWithImplements'));
77 77
                     eval("?>$content");
78 78
                 }
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
      *
88 88
      * @throws FileNotFoundException
89 89
      */
90
-    public function createClassImplements($implements=array())
90
+    public function createClassImplements($implements = array())
91 91
     {
92
-        if(!is_null($this->getClassString())){
92
+        if (!is_null($this->getClassString())) {
93 93
 
94 94
             $implementList = [];
95 95
             $implementUseList = [];
96 96
 
97
-            foreach($implements as $namespace=>$alias) {
97
+            foreach ($implements as $namespace=>$alias) {
98 98
                 $implementUseList[] = $namespace;
99 99
                 $implementList[] = $alias;
100 100
             }
@@ -114,26 +114,26 @@  discard block
 block discarded – undo
114 114
      *
115 115
      * @throws FileNotFoundException
116 116
      */
117
-    public function createClassProperty($properties=array(),$loadedMethod=false)
117
+    public function createClassProperty($properties = array(), $loadedMethod = false)
118 118
     {
119
-        if(is_null($this->classProperties)){
119
+        if (is_null($this->classProperties)) {
120 120
             $this->classProperties = $properties;
121 121
         }
122 122
 
123
-        if(isset($this->loaded['createMethod'])){
123
+        if (isset($this->loaded['createMethod'])) {
124 124
             $this->classProperties = $properties;
125 125
             $loadedMethod = true;
126 126
         }
127 127
 
128
-        if($loadedMethod){
128
+        if ($loadedMethod) {
129 129
             foreach ($this->classProperties as $property) {
130
-                if(!preg_match('@'.$this->regexEscape($property).'@',$this->fileSystem->get($this->file))){
130
+                if (!preg_match('@'.$this->regexEscape($property).'@', $this->fileSystem->get($this->file))) {
131 131
                     $content = '<?php'.$this->fileSystem->get($this->getEval('createClassProperty'));
132 132
                     eval("?>$content");
133 133
                 }
134 134
             }
135 135
 
136
-            if(isset($this->loaded['createClassPropertyDocument'])){
136
+            if (isset($this->loaded['createClassPropertyDocument'])) {
137 137
                 $this->createClassPropertyDocument($this->loaded['createClassPropertyDocument']);
138 138
             }
139 139
         }
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
      *
147 147
      * @throws FileNotFoundException
148 148
      */
149
-    public function createClassPropertyDocument($properties=array())
149
+    public function createClassPropertyDocument($properties = array())
150 150
     {
151 151
         $this->loaded['createClassPropertyDocument'] = $properties;
152 152
 
153
-        foreach ($properties as $property=>$documents){
153
+        foreach ($properties as $property=>$documents) {
154 154
             $content = '<?php'.$this->fileSystem->get($this->getEval('createClassPropertyDocument'));
155 155
             eval("?>$content");
156 156
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function createClassTrait($trait)
167 167
     {
168
-        if(isset($this->loaded['createClass']) && is_string($trait)){
168
+        if (isset($this->loaded['createClass']) && is_string($trait)) {
169 169
             $content = '<?php'.$this->fileSystem->get($this->getEval('createClassTrait'));
170 170
             eval("?>$content");
171 171
         }
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
      *
179 179
      * @throws FileNotFoundException
180 180
      */
181
-    public function createClassUse($uses=array())
181
+    public function createClassUse($uses = array())
182 182
     {
183
-        if(!is_null($this->getClassString()) && count($uses)){
183
+        if (!is_null($this->getClassString()) && count($uses)) {
184 184
             $content = '<?php'.$this->fileSystem->get($this->getEval('createClassUse'));
185 185
             eval("?>$content");
186 186
         }
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
      *
194 194
      * @throws FileNotFoundException
195 195
      */
196
-    public function createMethod($methods=array())
196
+    public function createMethod($methods = array())
197 197
     {
198
-        if(preg_match('@'.$this->type.'\s.*\n{@',$this->fileSystem->get($this->file),$parse) && count($methods)){
198
+        if (preg_match('@'.$this->type.'\s.*\n{@', $this->fileSystem->get($this->file), $parse) && count($methods)) {
199 199
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethod'));
200 200
             eval("?>$content");
201 201
 
202
-            $this->createClassProperty([],true);
202
+            $this->createClassProperty([], true);
203 203
             $this->loaded['createMethod'] = true;
204 204
         }
205 205
     }
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
      *
212 212
      * @throws FileNotFoundException
213 213
      */
214
-    public function createMethodAbstract($methods=array())
214
+    public function createMethodAbstract($methods = array())
215 215
     {
216
-        if(preg_match('@'.$this->type.'\s.*\n{@',$this->fileSystem->get($this->file),$parse) && count($methods)){
216
+        if (preg_match('@'.$this->type.'\s.*\n{@', $this->fileSystem->get($this->file), $parse) && count($methods)) {
217 217
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodAbstract'));
218 218
             eval("?>$content");
219 219
 
220
-            $this->createClassProperty([],true);
220
+            $this->createClassProperty([], true);
221 221
             $this->loaded['createMethod'] = true;
222 222
         }
223 223
     }
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
      *
231 231
      * @throws FileNotFoundException
232 232
      */
233
-    public function createMethodAccessibleProperty($methods=array())
233
+    public function createMethodAccessibleProperty($methods = array())
234 234
     {
235
-        foreach($methods as $method=>$accessibleValue){
235
+        foreach ($methods as $method=>$accessibleValue) {
236 236
             $this->accessibleProperties[$method] = $accessibleValue;
237 237
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodAccessibleProperty'));
238 238
             eval("?>$content");
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
      *
247 247
      * @throws FileNotFoundException
248 248
      */
249
-    public function createMethodBody($methods=array())
249
+    public function createMethodBody($methods = array())
250 250
     {
251
-        foreach ($methods as $method=>$body){
251
+        foreach ($methods as $method=>$body) {
252 252
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodBody'));
253 253
             eval("?>$content");
254 254
         }
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
      *
262 262
      * @throws FileNotFoundException
263 263
      */
264
-    public function createMethodAbstractDocument($methods=array())
264
+    public function createMethodAbstractDocument($methods = array())
265 265
     {
266
-        foreach ($methods as $method=>$documents){
266
+        foreach ($methods as $method=>$documents) {
267 267
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodAbstractDocument'));
268 268
             eval("?>$content");
269 269
         }
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
      *
277 277
      * @throws FileNotFoundException
278 278
      */
279
-    public function createMethodDocument($methods=array())
279
+    public function createMethodDocument($methods = array())
280 280
     {
281
-        foreach ($methods as $method=>$documents){
281
+        foreach ($methods as $method=>$documents) {
282 282
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodDocument'));
283 283
             eval("?>$content");
284 284
         }
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
      *
292 292
      * @throws FileNotFoundException
293 293
      */
294
-    public function createMethodImplement($methods=array())
294
+    public function createMethodImplement($methods = array())
295 295
     {
296
-        if(preg_match('@'.$this->type.'\s.*\n{@',$this->fileSystem->get($this->file),$parse) && count($methods)){
296
+        if (preg_match('@'.$this->type.'\s.*\n{@', $this->fileSystem->get($this->file), $parse) && count($methods)) {
297 297
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodImplement'));
298 298
             eval("?>$content");
299 299
 
300
-            $this->createClassProperty([],true);
300
+            $this->createClassProperty([], true);
301 301
             $this->loaded['createMethod'] = true;
302 302
         }
303 303
     }
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
      *
310 310
      * @throws FileNotFoundException
311 311
      */
312
-    public function createMethodImplementDocument($methods=array())
312
+    public function createMethodImplementDocument($methods = array())
313 313
     {
314
-        foreach ($methods as $method=>$documents){
314
+        foreach ($methods as $method=>$documents) {
315 315
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodImplementDocument'));
316 316
             eval("?>$content");
317 317
         }
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
      *
326 326
      * @throws FileNotFoundException
327 327
      */
328
-    public function createMethodParameters($methods=array())
328
+    public function createMethodParameters($methods = array())
329 329
     {
330
-        foreach($methods as $method=>$parameter) {
330
+        foreach ($methods as $method=>$parameter) {
331 331
             $this->methodParameters[$method] = $parameter;
332 332
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodParameters'));
333 333
             eval("?>$content");
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
      *
343 343
      * @throws FileNotFoundException
344 344
      */
345
-    public function createMethodAbstractParameters($methods=array())
345
+    public function createMethodAbstractParameters($methods = array())
346 346
     {
347
-        foreach($methods as $method=>$parameter) {
347
+        foreach ($methods as $method=>$parameter) {
348 348
             $this->methodParameters[''.$this->type.'_'.$method] = $parameter;
349 349
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodAbstractParameters'));
350 350
             eval("?>$content");
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
      *
360 360
      * @throws FileNotFoundException
361 361
      */
362
-    public function createMethodImplementParameters($methods=array())
362
+    public function createMethodImplementParameters($methods = array())
363 363
     {
364
-        foreach($methods as $method=>$parameter) {
364
+        foreach ($methods as $method=>$parameter) {
365 365
             $this->methodParameters[''.$this->type.'_'.$method] = $parameter;
366 366
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodImplementParameters'));
367 367
             eval("?>$content");
Please login to merge, or discard this patch.
src/resta/Support/Generator/GeneratorAbstract.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -233,8 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
             if($default){
235 235
                 $search = '/'.$key.'/';
236
-            }
237
-            else{
236
+            } else{
238 237
                 $search = '/__'.$key.'__/';
239 238
             }
240 239
 
@@ -269,8 +268,7 @@  discard block
 block discarded – undo
269 268
     {
270 269
         if(is_null($stubPath)){
271 270
             $this->stubPath = __DIR__.'/stubs';
272
-        }
273
-        else{
271
+        } else{
274 272
             $this->stubPath = $stubPath;
275 273
         }
276 274
     }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * @param $name
84 84
      * @param Filesystem $fileSystem
85 85
      */
86
-    public function __construct($path,$name,Filesystem $fileSystem=null)
86
+    public function __construct($path, $name, Filesystem $fileSystem = null)
87 87
     {
88 88
         $this->format = $this->type;
89 89
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function createPath()
111 111
     {
112
-        if(!file_exists($this->path)){
113
-            if(!$this->fileSystem->makeDirectory($this->path)){
112
+        if (!file_exists($this->path)) {
113
+            if (!$this->fileSystem->makeDirectory($this->path)) {
114 114
                 throw new \Error($this->path.' makeDirectory fail');
115 115
             }
116 116
         }
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
      */
124 124
     protected function getClassInstance()
125 125
     {
126
-        if(!isset($this->loaded['createClass'])){
126
+        if (!isset($this->loaded['createClass'])) {
127 127
 
128
-            if(is_null(self::$instance)){
128
+            if (is_null(self::$instance)) {
129 129
                 $class = Utils::getNamespace($this->file);
130 130
                 self::$instance = new $class;
131 131
             }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     protected function getClassString()
158 158
     {
159
-        if(preg_match('@'.$this->type.'\s.*\n{@',$this->fileSystem->get($this->file),$parse)){
159
+        if (preg_match('@'.$this->type.'\s.*\n{@', $this->fileSystem->get($this->file), $parse)) {
160 160
             return $parse[0];
161 161
         }
162 162
 
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
      * @param null $eval
170 170
      * @return string
171 171
      */
172
-    protected function getEval($eval=null)
172
+    protected function getEval($eval = null)
173 173
     {
174
-        return __DIR__ . '/stubs/evals/' .$eval.'.stub';
174
+        return __DIR__.'/stubs/evals/'.$eval.'.stub';
175 175
     }
176 176
 
177 177
     /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param bool $regexEscape
182 182
      * @return mixed|string
183 183
      */
184
-    protected function getMethodParameters($method,$regexEscape=true)
184
+    protected function getMethodParameters($method, $regexEscape = true)
185 185
     {
186 186
         return  (isset($this->methodParameters[$method])) ?
187 187
             ($regexEscape) ? $this->regexEscape($this->methodParameters[$method]) : $this->methodParameters[$method]
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     {
198 198
         $stubFile = $this->stubPath.''.DIRECTORY_SEPARATOR.''.$this->format.'.stub';
199 199
 
200
-        if(!file_exists($stubFile)){
200
+        if (!file_exists($stubFile)) {
201 201
             throw new \Error($stubFile.' path is not available');
202 202
         }
203 203
 
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
      */
213 213
     protected function regexEscape($data)
214 214
     {
215
-        $dataEscape = str_replace('\\','\\\\',$data);
216
-        $dataEscape = str_replace('$','\$',$dataEscape);
217
-        $dataEscape = str_replace('()','\(\)',$dataEscape);
218
-        $dataEscape = str_replace('[]','\[\]',$dataEscape);
215
+        $dataEscape = str_replace('\\', '\\\\', $data);
216
+        $dataEscape = str_replace('$', '\$', $dataEscape);
217
+        $dataEscape = str_replace('()', '\(\)', $dataEscape);
218
+        $dataEscape = str_replace('[]', '\[\]', $dataEscape);
219 219
 
220 220
 
221 221
         return $dataEscape;
@@ -231,24 +231,24 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @throws \Resta\Exception\FileNotFoundException
233 233
      */
234
-    protected function replaceFileContent($replacement,$file,$default=false)
234
+    protected function replaceFileContent($replacement, $file, $default = false)
235 235
     {
236 236
         $replacementVariables = ($default) ? $replacement : $this->replacementVariables($replacement);
237 237
         $content = $this->fileSystem->get($file);
238 238
 
239
-        foreach ($replacementVariables as $key=>$replacementVariable){
239
+        foreach ($replacementVariables as $key=>$replacementVariable) {
240 240
 
241
-            if($default){
241
+            if ($default) {
242 242
                 $search = '/'.$key.'/';
243 243
             }
244
-            else{
244
+            else {
245 245
                 $search = '/__'.$key.'__/';
246 246
             }
247 247
 
248 248
             $replace = $replacementVariable;
249
-            $content = preg_replace($search,$replace,$content);
249
+            $content = preg_replace($search, $replace, $content);
250 250
         }
251
-        $this->fileSystem->replace($file,$content);
251
+        $this->fileSystem->replace($file, $content);
252 252
     }
253 253
 
254 254
     /**
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
      * @param array $replacement
258 258
      * @return array
259 259
      */
260
-    protected function replacementVariables($replacement=array())
260
+    protected function replacementVariables($replacement = array())
261 261
     {
262 262
         $replacement['namespace'] = $this->namespace;
263 263
         $replacement['class'] = $this->name;
264 264
 
265
-        return array_map(function($item){
265
+        return array_map(function($item) {
266 266
             return ucfirst($item);
267 267
         },$replacement);
268 268
     }
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $this->format = $format;
278 278
 
279
-        if($this->format=='abstract'){
279
+        if ($this->format=='abstract') {
280 280
             $this->type = 'abstract class';
281 281
         }
282 282
 
283
-        if($this->format=='interface'){
283
+        if ($this->format=='interface') {
284 284
             $this->type = $this->format;
285 285
         }
286 286
     }
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
      *
291 291
      * @param $stubPath
292 292
      */
293
-    public function setStubPath($stubPath=null)
293
+    public function setStubPath($stubPath = null)
294 294
     {
295
-        if(is_null($stubPath)){
295
+        if (is_null($stubPath)) {
296 296
             $this->stubPath = __DIR__.'/stubs';
297 297
         }
298
-        else{
298
+        else {
299 299
             $this->stubPath = $stubPath;
300 300
         }
301 301
     }
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/Schema.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
      * Schema constructor.
41 41
      * @param null|mixed $config
42 42
      */
43
-    public function __construct($config=null)
43
+    public function __construct($config = null)
44 44
     {
45 45
         $this->config           = $config;
46 46
         $this->driver           = $this->config['database']['driver'];
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/SchemaFacade.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      * SchemaFacade constructor.
29 29
      * @param array $config
30 30
      */
31
-    public function __construct($config=array())
31
+    public function __construct($config = array())
32 32
     {
33
-        if(count($config)){
33
+        if (count($config)) {
34 34
             $this->schema = new Schema($config);
35 35
         }
36 36
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param array $params
42 42
      * @return SchemaFacade
43 43
      */
44
-    public static function setConfig($params=array())
44
+    public static function setConfig($params = array())
45 45
     {
46 46
         self::$config = $params;
47 47
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @param array $tables
55 55
      * @return SchemaFacade
56 56
      */
57
-    public static function tables($tables=array())
57
+    public static function tables($tables = array())
58 58
     {
59 59
         self::$tables = $tables;
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public static function getInstance()
70 70
     {
71
-        if(is_null(self::$instance)){
71
+        if (is_null(self::$instance)) {
72 72
             self::$instance = new self(self::$config);
73 73
         }
74 74
 
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/Resource/BaseManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected function getClassName($file)
62 62
     {
63
-        $className = str_replace(".php","",BaseRequestProcess::getFileName($file));
63
+        $className = str_replace(".php", "", BaseRequestProcess::getFileName($file));
64 64
 
65 65
         return $className;
66 66
     }
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
      * @param null|string $data
101 101
      * @return mixed
102 102
      */
103
-    public function queryBuilder($table=null,$data=null)
103
+    public function queryBuilder($table = null, $data = null)
104 104
     {
105 105
         $queryBuilder = $this->queryBuilder;
106 106
 
107
-        return new $queryBuilder($this->schema,$table,$data);
107
+        return new $queryBuilder($this->schema, $table, $data);
108 108
     }
109 109
 
110 110
     /**
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 
121 121
         foreach ($this->getAllFiles() as $table=>$allFile) {
122 122
 
123
-            if(count($tables)){
123
+            if (count($tables)) {
124 124
 
125
-                if(in_array($table,$tables)){
126
-                    $list[$table]=$allFile;
125
+                if (in_array($table, $tables)) {
126
+                    $list[$table] = $allFile;
127 127
                 }
128 128
             }
129 129
         }
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
      * @param array $params
137 137
      * @return mixed
138 138
      */
139
-    public function getContentFile($path,$params=array())
139
+    public function getContentFile($path, $params = array())
140 140
     {
141 141
         $dt = fopen($path, "r");
142 142
         $content = fread($dt, filesize($path));
143 143
         fclose($dt);
144 144
 
145
-        foreach ($params as $key=>$value){
145
+        foreach ($params as $key=>$value) {
146 146
 
147
-            $content=str_replace("__".$key."__",$value,$content);
147
+            $content = str_replace("__".$key."__", $value, $content);
148 148
         }
149 149
 
150 150
         return $content;
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/Resource/PullManager/Pulling.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
 
21 21
         $list = [];
22 22
 
23
-        foreach ($migrations as $table=>$item){
23
+        foreach ($migrations as $table=>$item) {
24 24
             $list[] = strtolower($table);
25 25
         }
26 26
 
27
-        foreach ($dbtables as $dbtable){
27
+        foreach ($dbtables as $dbtable) {
28 28
             //if(!in_array($dbtable,$list)){
29 29
 
30 30
                 $informations = $this->tableInformations($dbtable);
31 31
 
32 32
                 $dbtable = ucfirst($dbtable);
33 33
                 $makeDirectory = $directory.''.DIRECTORY_SEPARATOR.''.$dbtable;
34
-                files()->makeDirectory($makeDirectory,0755,true);
34
+                files()->makeDirectory($makeDirectory, 0755, true);
35 35
 
36 36
                 $migrationName = time().'_'.$dbtable.'';
37 37
 
38
-                $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub',[
38
+                $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub', [
39 39
                     'className' => $dbtable,
40 40
                     'informations' => $informations
41 41
                 ]);
42 42
 
43
-                files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php',$content);
43
+                files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php', $content);
44 44
             //}
45 45
         }
46 46
     }
@@ -64,44 +64,44 @@  discard block
 block discarded – undo
64 64
 
65 65
         $list = [];
66 66
 
67
-        foreach ($columns as $key=>$data){
67
+        foreach ($columns as $key=>$data) {
68 68
 
69 69
             $field      = $data['Field'];
70 70
             $list[]     = '$wizard->name(\''.$field.'\')';
71 71
             $list[]     = '->'.$this->getColumnTransformers($data['Type']).'';
72 72
 
73 73
             //default block
74
-            if(!is_null($data['Default'])){
74
+            if (!is_null($data['Default'])) {
75 75
                 $default = $data['Default'];
76
-                $list[]     = '->default(\''.$default.'\')';
76
+                $list[] = '->default(\''.$default.'\')';
77 77
             }
78 78
 
79
-            $getIndex = $this->getIndexInformation($indexes,$data['Field']);
79
+            $getIndex = $this->getIndexInformation($indexes, $data['Field']);
80 80
 
81 81
             //unique block
82
-            if($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY'){
82
+            if ($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY') {
83 83
                 $indexName = $getIndex['Key_name'];
84
-                $list[]     = '->unique(\''.$indexName.'\')';
84
+                $list[] = '->unique(\''.$indexName.'\')';
85 85
             }
86 86
 
87 87
             //index block
88
-            if($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY'){
88
+            if ($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY') {
89 89
                 $columnName = $getIndex['Column_name'];
90 90
                 $indexName = $getIndex['Key_name'];
91 91
 
92
-                if(count($multipleIndexes[$indexName])==1){
92
+                if (count($multipleIndexes[$indexName])==1) {
93 93
                     $list[] = '->index(\''.$indexName.'\')';
94 94
                 }
95 95
             }
96 96
 
97 97
             //comment block
98
-            if(strlen($data['Comment'])>0){
98
+            if (strlen($data['Comment'])>0) {
99 99
                 $comment = $data['Comment'];
100 100
                 $list[] = '->comment(\''.$comment.'\')';
101 101
             }
102 102
 
103 103
             //auto increment block
104
-            if($data['Extra']=='auto_increment'){
104
+            if ($data['Extra']=='auto_increment') {
105 105
                 $list[] = '->auto_increment()';
106 106
             }
107 107
 
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
 
117 117
         //table indexes
118 118
         foreach ($multipleIndexes as $indexName=>$values) {
119
-            if(count($values)>1){
120
-                $values = '\''.implode('\',\'',$values).'\'';
119
+            if (count($values)>1) {
120
+                $values = '\''.implode('\',\'', $values).'\'';
121 121
                 $list[] = '    $wizard->table()->indexes(\''.$indexName.'\',['.$values.']);
122 122
                 ';
123 123
             }
124 124
         }
125 125
 
126
-        if(count($foreignKeys)){
126
+        if (count($foreignKeys)) {
127 127
 
128 128
             $constraintName = $foreignKeys['CONSTRAINT_NAME'];
129 129
             $key = $foreignKeys['COLUMN_NAME'];
130 130
             $referenceTable = $foreignKeys['REFERENCED_TABLE_NAME'];
131 131
             $referenceColumn = $foreignKeys['REFERENCED_COLUMN_NAME'];
132 132
 
133
-            if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){
133
+            if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') {
134 134
                 $list[] = '    $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\');
135 135
                 ';
136 136
             }
137 137
 
138
-            if($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){
138
+            if ($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') {
139 139
                 $rule = $foreignKeys['UPDATE_RULE'];
140 140
                 $list[] = '    $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onUpdate()->'.strtolower($rule).'();
141 141
                 ';
142 142
             }
143 143
 
144
-            if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT'){
144
+            if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT') {
145 145
                 $rule = $foreignKeys['DELETE_RULE'];
146 146
                 $list[] = '    $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onDelete()->'.strtolower($rule).'();
147 147
                 ';
148 148
             }
149 149
         }
150 150
 
151
-        return implode('',$list);
151
+        return implode('', $list);
152 152
     }
153 153
 
154 154
     /**
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
      */
160 160
     private function getColumnTransformers($column)
161 161
     {
162
-        if($column=='datetime'){
162
+        if ($column=='datetime') {
163 163
             return 'datetime()';
164 164
         }
165
-        elseif($column=='longtext'){
165
+        elseif ($column=='longtext') {
166 166
             return 'longtext()';
167 167
         }
168
-        elseif($column=='date'){
168
+        elseif ($column=='date') {
169 169
             return 'date()';
170 170
         }
171
-        elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){
171
+        elseif (preg_match('@enum.*\((.*?)\)@', $column, $enum)) {
172 172
             return 'enum(['.$enum[1].'])';
173 173
         }
174
-        else{
174
+        else {
175 175
             return $column;
176 176
         }
177 177
     }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
      * @param $field
184 184
      * @return void|mixed
185 185
      */
186
-    private function getIndexInformation($index,$field)
186
+    private function getIndexInformation($index, $field)
187 187
     {
188 188
         foreach ($index as $key=>$item) {
189 189
 
190
-            if($item['Column_name'] == $field){
190
+            if ($item['Column_name']==$field) {
191 191
                 return $index[$key];
192 192
             }
193 193
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     {
207 207
         $list = [];
208 208
         foreach ($index as $key=>$item) {
209
-            if($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY'){
209
+            if ($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY') {
210 210
                 $list[$item['Key_name']][] = $item['Column_name'];
211 211
             }
212 212
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -161,17 +161,13 @@
 block discarded – undo
161 161
     {
162 162
         if($column=='datetime'){
163 163
             return 'datetime()';
164
-        }
165
-        elseif($column=='longtext'){
164
+        } elseif($column=='longtext'){
166 165
             return 'longtext()';
167
-        }
168
-        elseif($column=='date'){
166
+        } elseif($column=='date'){
169 167
             return 'date()';
170
-        }
171
-        elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){
168
+        } elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){
172 169
             return 'enum(['.$enum[1].'])';
173
-        }
174
-        else{
170
+        } else{
175 171
             return $column;
176 172
         }
177 173
     }
Please login to merge, or discard this patch.
src/resta/Database/Migration/Src/Resource/PushManager/Pushing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,18 +22,18 @@
 block discarded – undo
22 22
      */
23 23
     public function handle()
24 24
     {
25
-        foreach ($this->tableFilters() as $table=>$files){
25
+        foreach ($this->tableFilters() as $table=>$files) {
26 26
 
27 27
             $table = strtolower($table);
28 28
 
29 29
             foreach ($files as $file) {
30 30
 
31
-                $getClassName = preg_replace('@(\d+)_@is','',$file);
31
+                $getClassName = preg_replace('@(\d+)_@is', '', $file);
32 32
                 $className = $this->getClassName($getClassName);
33 33
 
34 34
                 require_once ($file);
35 35
 
36
-                $capsule = new SchemaCapsule($this->config,$file,$table);
36
+                $capsule = new SchemaCapsule($this->config, $file, $table);
37 37
 
38 38
                 $this->list[$table][] = (new $className)->up($capsule);
39 39
             }
Please login to merge, or discard this patch.