Test Setup Failed
Push — master ( a3b2d5...39ac68 )
by Php Easy Api
04:18 queued 13s
created
src/resta/Support/Generator/Generator.php 2 patches
Spacing   +39 added lines, -39 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('@class\s.*\n{@',$this->fileSystem->get($this->file),$parse) && count($methods)){
198
+        if (preg_match('@class\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
     }
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      *
213 213
      * @throws FileNotFoundException
214 214
      */
215
-    public function createMethodAccessibleProperty($methods=array())
215
+    public function createMethodAccessibleProperty($methods = array())
216 216
     {
217
-        foreach($methods as $method=>$accessibleValue){
217
+        foreach ($methods as $method=>$accessibleValue) {
218 218
             $this->accessibleProperties[$method] = $accessibleValue;
219 219
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodAccessibleProperty'));
220 220
             eval("?>$content");
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
      *
229 229
      * @throws FileNotFoundException
230 230
      */
231
-    public function createMethodBody($methods=array())
231
+    public function createMethodBody($methods = array())
232 232
     {
233
-        foreach ($methods as $method=>$body){
233
+        foreach ($methods as $method=>$body) {
234 234
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodBody'));
235 235
             eval("?>$content");
236 236
         }
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
      *
244 244
      * @throws FileNotFoundException
245 245
      */
246
-    public function createMethodDocument($methods=array())
246
+    public function createMethodDocument($methods = array())
247 247
     {
248
-        foreach ($methods as $method=>$documents){
248
+        foreach ($methods as $method=>$documents) {
249 249
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodDocument'));
250 250
             eval("?>$content");
251 251
         }
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
      *
260 260
      * @throws FileNotFoundException
261 261
      */
262
-    public function createMethodParameters($methods=array())
262
+    public function createMethodParameters($methods = array())
263 263
     {
264
-        foreach($methods as $method=>$parameter) {
264
+        foreach ($methods as $method=>$parameter) {
265 265
             $this->methodParameters[$method] = $parameter;
266 266
             $content = '<?php'.$this->fileSystem->get($this->getEval('createMethodParameters'));
267 267
             eval("?>$content");
Please login to merge, or discard this patch.
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.
src/resta/Support/Generator/GeneratorAbstract.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param $name
79 79
      * @param Filesystem $fileSystem
80 80
      */
81
-    public function __construct($path,$name,Filesystem $fileSystem=null)
81
+    public function __construct($path, $name, Filesystem $fileSystem = null)
82 82
     {
83 83
         $this->path = $path;
84 84
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function createPath()
104 104
     {
105
-        if(!file_exists($this->path)){
106
-            if(!$this->fileSystem->makeDirectory($this->path)){
105
+        if (!file_exists($this->path)) {
106
+            if (!$this->fileSystem->makeDirectory($this->path)) {
107 107
                 throw new \Error($this->path.' makeDirectory fail');
108 108
             }
109 109
         }
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
      */
117 117
     protected function getClassInstance()
118 118
     {
119
-        if(!isset($this->loaded['createClass'])){
119
+        if (!isset($this->loaded['createClass'])) {
120 120
 
121
-            if(is_null(self::$instance)){
121
+            if (is_null(self::$instance)) {
122 122
                 $class = Utils::getNamespace($this->file);
123 123
                 self::$instance = new $class;
124 124
             }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     protected function getClassString()
151 151
     {
152
-        if(preg_match('@class\s.*\n{@',$this->fileSystem->get($this->file),$parse)){
152
+        if (preg_match('@class\s.*\n{@', $this->fileSystem->get($this->file), $parse)) {
153 153
             return $parse[0];
154 154
         }
155 155
 
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
      * @param null $eval
163 163
      * @return string
164 164
      */
165
-    protected function getEval($eval=null)
165
+    protected function getEval($eval = null)
166 166
     {
167
-        return __DIR__ . '/stubs/evals/' .$eval.'.stub';
167
+        return __DIR__.'/stubs/evals/'.$eval.'.stub';
168 168
     }
169 169
 
170 170
     /**
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * @param bool $regexEscape
175 175
      * @return mixed|string
176 176
      */
177
-    protected function getMethodParameters($method,$regexEscape=true)
177
+    protected function getMethodParameters($method, $regexEscape = true)
178 178
     {
179 179
         return  (isset($this->methodParameters[$method])) ?
180 180
             ($regexEscape) ? $this->regexEscape($this->methodParameters[$method]) : $this->methodParameters[$method]
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     {
191 191
         $stubFile = $this->stubPath.''.DIRECTORY_SEPARATOR.''.$this->type.'.stub';
192 192
 
193
-        if(!file_exists($stubFile)){
193
+        if (!file_exists($stubFile)) {
194 194
             throw new \Error($stubFile.' path is not available');
195 195
         }
196 196
 
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
      */
206 206
     protected function regexEscape($data)
207 207
     {
208
-        $dataEscape = str_replace('\\','\\\\',$data);
209
-        $dataEscape = str_replace('$','\$',$dataEscape);
210
-        $dataEscape = str_replace('()','\(\)',$dataEscape);
211
-        $dataEscape = str_replace('[]','\[\]',$dataEscape);
208
+        $dataEscape = str_replace('\\', '\\\\', $data);
209
+        $dataEscape = str_replace('$', '\$', $dataEscape);
210
+        $dataEscape = str_replace('()', '\(\)', $dataEscape);
211
+        $dataEscape = str_replace('[]', '\[\]', $dataEscape);
212 212
 
213 213
 
214 214
         return $dataEscape;
@@ -224,24 +224,24 @@  discard block
 block discarded – undo
224 224
      *
225 225
      * @throws \Resta\Exception\FileNotFoundException
226 226
      */
227
-    protected function replaceFileContent($replacement,$file,$default=false)
227
+    protected function replaceFileContent($replacement, $file, $default = false)
228 228
     {
229 229
         $replacementVariables = ($default) ? $replacement : $this->replacementVariables($replacement);
230 230
         $content = $this->fileSystem->get($file);
231 231
 
232
-        foreach ($replacementVariables as $key=>$replacementVariable){
232
+        foreach ($replacementVariables as $key=>$replacementVariable) {
233 233
 
234
-            if($default){
234
+            if ($default) {
235 235
                 $search = '/'.$key.'/';
236 236
             }
237
-            else{
237
+            else {
238 238
                 $search = '/__'.$key.'__/';
239 239
             }
240 240
 
241 241
             $replace = $replacementVariable;
242
-            $content = preg_replace($search,$replace,$content);
242
+            $content = preg_replace($search, $replace, $content);
243 243
         }
244
-        $this->fileSystem->replace($file,$content);
244
+        $this->fileSystem->replace($file, $content);
245 245
     }
246 246
 
247 247
     /**
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
      * @param array $replacement
251 251
      * @return array
252 252
      */
253
-    protected function replacementVariables($replacement=array())
253
+    protected function replacementVariables($replacement = array())
254 254
     {
255 255
         $replacement['namespace'] = $this->namespace;
256 256
         $replacement['class'] = $this->name;
257 257
 
258
-        return array_map(function($item){
258
+        return array_map(function($item) {
259 259
             return ucfirst($item);
260 260
         },$replacement);
261 261
     }
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
      *
266 266
      * @param $stubPath
267 267
      */
268
-    public function setStubPath($stubPath=null)
268
+    public function setStubPath($stubPath = null)
269 269
     {
270
-        if(is_null($stubPath)){
270
+        if (is_null($stubPath)) {
271 271
             $this->stubPath = __DIR__.'/stubs';
272 272
         }
273
-        else{
273
+        else {
274 274
             $this->stubPath = $stubPath;
275 275
         }
276 276
     }
Please login to merge, or discard this patch.
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.