@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param null|string $name |
79 | 79 | * @param null|object $fileSystem |
80 | 80 | */ |
81 | - public function __construct($path=null,$name=null,$fileSystem=null) |
|
81 | + public function __construct($path = null, $name = null, $fileSystem = null) |
|
82 | 82 | { |
83 | 83 | $this->path = $path; |
84 | 84 | |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @throws FileNotFoundException |
105 | 105 | */ |
106 | - public function createClass($replacement=array()) |
|
106 | + public function createClass($replacement = array()) |
|
107 | 107 | { |
108 | - if(file_exists($this->path)){ |
|
108 | + if (file_exists($this->path)) { |
|
109 | 109 | |
110 | 110 | $content = $this->fileSystem->get($this->getStubFile()); |
111 | 111 | |
112 | 112 | $this->loaded['createClass'] = true; |
113 | 113 | |
114 | - if($this->fileSystem->put($this->file,$content)!==FALSE){ |
|
115 | - $this->replaceFileContent($replacement,$this->file); |
|
114 | + if ($this->fileSystem->put($this->file, $content)!==FALSE) { |
|
115 | + $this->replaceFileContent($replacement, $this->file); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @throws FileNotFoundException |
128 | 128 | */ |
129 | - public function createClassDocument($documents=array()) |
|
129 | + public function createClassDocument($documents = array()) |
|
130 | 130 | { |
131 | - if(isset($this->loaded['createClass'])){ |
|
131 | + if (isset($this->loaded['createClass'])) { |
|
132 | 132 | |
133 | 133 | $documentString = []; |
134 | 134 | $documentString[] = '/**'; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | foreach ($documents as $document) { |
137 | 137 | |
138 | 138 | $documentString[] = ' |
139 | -* ' . $document . ''; |
|
139 | +* ' . $document.''; |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */'; |
145 | 145 | |
146 | 146 | $this->replaceFileContent([ |
147 | - 'class\s.*\n{' => implode('',$documentString).' |
|
147 | + 'class\s.*\n{' => implode('', $documentString).' |
|
148 | 148 | '.$this->getClassString() |
149 | - ],$this->file,true); |
|
149 | + ], $this->file, true); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -162,35 +162,35 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function createClassExtend($namespace, $alias) |
164 | 164 | { |
165 | - if(!preg_match('@extends@',$this->getClassString())){ |
|
165 | + if (!preg_match('@extends@', $this->getClassString())) { |
|
166 | 166 | |
167 | - if(preg_match('@class\s(.*?).*@',$this->getClassString(),$class)){ |
|
167 | + if (preg_match('@class\s(.*?).*@', $this->getClassString(), $class)) { |
|
168 | 168 | |
169 | - $statements = explode(' ',$class[0]); |
|
169 | + $statements = explode(' ', $class[0]); |
|
170 | 170 | |
171 | 171 | $className = $statements[1]; |
172 | 172 | |
173 | - if(count($statements)>2){ |
|
174 | - $implements = implode(' ',array_slice($statements,2)); |
|
173 | + if (count($statements)>2) { |
|
174 | + $implements = implode(' ', array_slice($statements, 2)); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | $this->createClassUse([ |
178 | 178 | $namespace |
179 | 179 | ]); |
180 | 180 | |
181 | - if(isset($implements)){ |
|
181 | + if (isset($implements)) { |
|
182 | 182 | |
183 | 183 | $this->replaceFileContent([ |
184 | 184 | 'class\s.*\n{' =>'class '.$className.' extends '.$alias.' '.$implements.' |
185 | 185 | {' |
186 | - ],$this->file,true); |
|
186 | + ], $this->file, true); |
|
187 | 187 | } |
188 | - else{ |
|
188 | + else { |
|
189 | 189 | |
190 | 190 | $this->replaceFileContent([ |
191 | 191 | 'class\s.*\n{' =>'class '.$className.' extends '.$alias.' |
192 | 192 | {' |
193 | - ],$this->file,true); |
|
193 | + ], $this->file, true); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @throws FileNotFoundException |
205 | 205 | */ |
206 | - public function createClassImplements($implements=array()) |
|
206 | + public function createClassImplements($implements = array()) |
|
207 | 207 | { |
208 | - if(!is_null($this->getClassString())){ |
|
208 | + if (!is_null($this->getClassString())) { |
|
209 | 209 | |
210 | 210 | $implementList = []; |
211 | 211 | $implementUseList = []; |
212 | 212 | |
213 | - foreach($implements as $namespace=>$alias) |
|
213 | + foreach ($implements as $namespace=>$alias) |
|
214 | 214 | { |
215 | 215 | $implementUseList[] = $namespace; |
216 | 216 | |
@@ -219,41 +219,41 @@ discard block |
||
219 | 219 | |
220 | 220 | $this->createClassUse($implementUseList); |
221 | 221 | |
222 | - if(preg_match('@class.*(.*?).*@',$this->getClassString(),$strings)){ |
|
223 | - $statements = explode(' ',$strings[0]); |
|
222 | + if (preg_match('@class.*(.*?).*@', $this->getClassString(), $strings)) { |
|
223 | + $statements = explode(' ', $strings[0]); |
|
224 | 224 | |
225 | 225 | $className = $statements[1]; |
226 | 226 | |
227 | - if(in_array('extends',$statements) && !in_array('implements',$statements)){ |
|
228 | - $extendsAliasName = $statements[array_search('extends',$statements)+1]; |
|
227 | + if (in_array('extends', $statements) && !in_array('implements', $statements)) { |
|
228 | + $extendsAliasName = $statements[array_search('extends', $statements)+1]; |
|
229 | 229 | |
230 | 230 | $this->replaceFileContent([ |
231 | - 'class\s.*\n{' =>'class '.$className.' extends '.$extendsAliasName.' implements '.implode(',',$implementList).' |
|
231 | + 'class\s.*\n{' =>'class '.$className.' extends '.$extendsAliasName.' implements '.implode(',', $implementList).' |
|
232 | 232 | {' |
233 | - ],$this->file,true); |
|
233 | + ], $this->file, true); |
|
234 | 234 | } |
235 | - elseif(in_array('extends',$statements) && in_array('implements',$statements)){ |
|
235 | + elseif (in_array('extends', $statements) && in_array('implements', $statements)) { |
|
236 | 236 | |
237 | - $extendsAliasName = $statements[array_search('extends',$statements)+1]; |
|
237 | + $extendsAliasName = $statements[array_search('extends', $statements)+1]; |
|
238 | 238 | |
239 | 239 | $this->replaceFileContent([ |
240 | - 'class\s.*\n{' =>'class '.$className.' extends '.$extendsAliasName.' implements '.end($statements).','.implode(',',$implementList).' |
|
240 | + 'class\s.*\n{' =>'class '.$className.' extends '.$extendsAliasName.' implements '.end($statements).','.implode(',', $implementList).' |
|
241 | 241 | {' |
242 | - ],$this->file,true); |
|
242 | + ], $this->file, true); |
|
243 | 243 | } |
244 | - elseif(!in_array('extends',$statements) && in_array('implements',$statements)){ |
|
244 | + elseif (!in_array('extends', $statements) && in_array('implements', $statements)) { |
|
245 | 245 | |
246 | 246 | $this->replaceFileContent([ |
247 | - 'class\s.*\n{' =>'class '.$className.' implements '.end($statements).','.implode(',',$implementList).' |
|
247 | + 'class\s.*\n{' =>'class '.$className.' implements '.end($statements).','.implode(',', $implementList).' |
|
248 | 248 | {' |
249 | - ],$this->file,true); |
|
249 | + ], $this->file, true); |
|
250 | 250 | } |
251 | - else{ |
|
251 | + else { |
|
252 | 252 | |
253 | 253 | $this->replaceFileContent([ |
254 | - 'class\s.*\n{' =>'class '.$className.' implements '.implode(',',$implementList).' |
|
254 | + 'class\s.*\n{' =>'class '.$className.' implements '.implode(',', $implementList).' |
|
255 | 255 | {' |
256 | - ],$this->file,true); |
|
256 | + ], $this->file, true); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
@@ -270,35 +270,35 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @throws FileNotFoundException |
272 | 272 | */ |
273 | - public function createClassProperty($properties=array(),$loadedMethod=false) |
|
273 | + public function createClassProperty($properties = array(), $loadedMethod = false) |
|
274 | 274 | { |
275 | - if(is_null($this->classProperties)){ |
|
275 | + if (is_null($this->classProperties)) { |
|
276 | 276 | $this->classProperties = $properties; |
277 | 277 | } |
278 | 278 | |
279 | - if(isset($this->loaded['createMethod'])){ |
|
279 | + if (isset($this->loaded['createMethod'])) { |
|
280 | 280 | $this->classProperties = $properties; |
281 | 281 | $loadedMethod = true; |
282 | 282 | } |
283 | 283 | |
284 | - if($loadedMethod){ |
|
284 | + if ($loadedMethod) { |
|
285 | 285 | |
286 | 286 | foreach ($this->classProperties as $property) { |
287 | 287 | |
288 | - if(!preg_match('@'.$this->regexEscape($property).'@',$this->fileSystem->get($this->file))){ |
|
288 | + if (!preg_match('@'.$this->regexEscape($property).'@', $this->fileSystem->get($this->file))) { |
|
289 | 289 | |
290 | - if(preg_match('@class\s.*\n{@',$this->fileSystem->get($this->file),$parse)){ |
|
290 | + if (preg_match('@class\s.*\n{@', $this->fileSystem->get($this->file), $parse)) { |
|
291 | 291 | $this->replaceFileContent([ |
292 | 292 | $parse[0] => $parse[0].' |
293 | 293 | '.$property.' |
294 | 294 | ' |
295 | 295 | |
296 | - ],$this->file,true); |
|
296 | + ], $this->file, true); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - if(isset($this->loaded['createClassPropertyDocument'])){ |
|
301 | + if (isset($this->loaded['createClassPropertyDocument'])) { |
|
302 | 302 | $this->createClassPropertyDocument($this->loaded['createClassPropertyDocument']); |
303 | 303 | } |
304 | 304 | } |
@@ -311,16 +311,16 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @throws FileNotFoundException |
313 | 313 | */ |
314 | - public function createClassPropertyDocument($properties=array()) |
|
314 | + public function createClassPropertyDocument($properties = array()) |
|
315 | 315 | { |
316 | 316 | $this->loaded['createClassPropertyDocument'] = $properties; |
317 | 317 | |
318 | - foreach ($properties as $property=>$documents){ |
|
318 | + foreach ($properties as $property=>$documents) { |
|
319 | 319 | |
320 | 320 | $documentString = []; |
321 | 321 | $documentString[] = '/**'; |
322 | 322 | |
323 | - foreach ($documents as $document){ |
|
323 | + foreach ($documents as $document) { |
|
324 | 324 | $documentString[] = ' |
325 | 325 | * '.$document.''; |
326 | 326 | } |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | */'; |
330 | 330 | |
331 | 331 | $this->replaceFileContent([ |
332 | - $this->regexEscape($property) => implode('',$documentString).' |
|
332 | + $this->regexEscape($property) => implode('', $documentString).' |
|
333 | 333 | '.$property |
334 | - ],$this->file,true); |
|
334 | + ], $this->file, true); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
@@ -344,13 +344,13 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function createClassTrait($trait) |
346 | 346 | { |
347 | - if(isset($this->loaded['createClass'])){ |
|
347 | + if (isset($this->loaded['createClass'])) { |
|
348 | 348 | |
349 | 349 | $this->replaceFileContent([ |
350 | 350 | 'class\s.*\n{' => $this->getClassString().' |
351 | 351 | use '.$trait.' |
352 | 352 | ' |
353 | - ],$this->file,true); |
|
353 | + ], $this->file, true); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -362,22 +362,22 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @throws FileNotFoundException |
364 | 364 | */ |
365 | - public function createClassUse($uses=array()) |
|
365 | + public function createClassUse($uses = array()) |
|
366 | 366 | { |
367 | - if(!is_null($this->getClassString())){ |
|
367 | + if (!is_null($this->getClassString())) { |
|
368 | 368 | |
369 | 369 | $useString = []; |
370 | 370 | |
371 | 371 | foreach ($uses as $use) { |
372 | 372 | |
373 | 373 | $useString[] = ' |
374 | -use ' . $use . ';'; |
|
374 | +use ' . $use.';'; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | $this->replaceFileContent([ |
378 | 378 | 'namespace '.$this->regexEscape($this->namespace).';' => 'namespace '.$this->namespace.'; |
379 | -'.implode('',$useString).'' |
|
380 | - ],$this->file,true); |
|
379 | +'.implode('', $useString).'' |
|
380 | + ], $this->file, true); |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @throws FileNotFoundException |
392 | 392 | */ |
393 | - public function createMethod($methods=array()) |
|
393 | + public function createMethod($methods = array()) |
|
394 | 394 | { |
395 | 395 | $list = []; |
396 | 396 | |
397 | - foreach ($methods as $method){ |
|
397 | + foreach ($methods as $method) { |
|
398 | 398 | |
399 | - if(!preg_match('@function.*'.$method.'@',$this->getClassString())){ |
|
399 | + if (!preg_match('@function.*'.$method.'@', $this->getClassString())) { |
|
400 | 400 | |
401 | 401 | $list[] = ' |
402 | 402 | '.$this->getAccessibleMethodValue($method).' function '.$method.'('.$this->getMethodParameters($method).') |
@@ -408,12 +408,12 @@ discard block |
||
408 | 408 | |
409 | 409 | |
410 | 410 | } |
411 | - if(preg_match('@class\s.*\n{@',$this->fileSystem->get($this->file),$parse)){ |
|
411 | + if (preg_match('@class\s.*\n{@', $this->fileSystem->get($this->file), $parse)) { |
|
412 | 412 | $this->replaceFileContent([ |
413 | - $parse[0] => $parse[0].' '.implode('',$list) |
|
414 | - ],$this->file,true); |
|
413 | + $parse[0] => $parse[0].' '.implode('', $list) |
|
414 | + ], $this->file, true); |
|
415 | 415 | |
416 | - $this->createClassProperty([],true); |
|
416 | + $this->createClassProperty([], true); |
|
417 | 417 | $this->loaded['createMethod'] = true; |
418 | 418 | } |
419 | 419 | |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @throws FileNotFoundException |
429 | 429 | */ |
430 | - public function createMethodAccessibleProperty($methods=array()) |
|
430 | + public function createMethodAccessibleProperty($methods = array()) |
|
431 | 431 | { |
432 | - foreach($methods as $method=>$accessibleValue) |
|
432 | + foreach ($methods as $method=>$accessibleValue) |
|
433 | 433 | { |
434 | 434 | $this->accessibleProperties[$method] = $accessibleValue; |
435 | 435 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | 'public function '.$method.'' => ''.$this->getAccessibleMethodValue($method).' function '.$method.'' |
439 | 439 | |
440 | - ],$this->file,true); |
|
440 | + ], $this->file, true); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -448,16 +448,16 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @throws FileNotFoundException |
450 | 450 | */ |
451 | - public function createMethodBody($methods=array()) |
|
451 | + public function createMethodBody($methods = array()) |
|
452 | 452 | { |
453 | - foreach ($methods as $method=>$body){ |
|
453 | + foreach ($methods as $method=>$body) { |
|
454 | 454 | |
455 | 455 | $this->replaceFileContent([ |
456 | 456 | ''.$this->getAccessibleMethodValue($method).' function '.$method.'\('.$this->getMethodParameters($method).'\)\n.*{\n.*\n.*}' => ''.$this->getAccessibleMethodValue($method).' function '.$method.'('.$this->getMethodParameters($method).') |
457 | 457 | { |
458 | 458 | '.$body.' |
459 | 459 | }' |
460 | - ],$this->file,true); |
|
460 | + ], $this->file, true); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
@@ -468,14 +468,14 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @throws FileNotFoundException |
470 | 470 | */ |
471 | - public function createMethodDocument($methods=array()) |
|
471 | + public function createMethodDocument($methods = array()) |
|
472 | 472 | { |
473 | - foreach ($methods as $method=>$documents){ |
|
473 | + foreach ($methods as $method=>$documents) { |
|
474 | 474 | |
475 | 475 | $documentString = []; |
476 | 476 | $documentString[] = '/**'; |
477 | 477 | |
478 | - foreach ($documents as $document){ |
|
478 | + foreach ($documents as $document) { |
|
479 | 479 | $documentString[] = ' |
480 | 480 | * '.$document.''; |
481 | 481 | } |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | */'; |
485 | 485 | |
486 | 486 | $this->replaceFileContent([ |
487 | - ''.$this->getAccessibleMethodValue($method).' function '.$method.'\('.$this->getMethodParameters($method).'\)' => ''.implode('',$documentString).' |
|
488 | - '.$this->getAccessibleMethodValue($method).' function '.$method.'('.$this->getMethodParameters($method,false).')' |
|
489 | - ],$this->file,true); |
|
487 | + ''.$this->getAccessibleMethodValue($method).' function '.$method.'\('.$this->getMethodParameters($method).'\)' => ''.implode('', $documentString).' |
|
488 | + '.$this->getAccessibleMethodValue($method).' function '.$method.'('.$this->getMethodParameters($method, false).')' |
|
489 | + ], $this->file, true); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @throws FileNotFoundException |
500 | 500 | */ |
501 | - public function createMethodParameters($methods=array()) |
|
501 | + public function createMethodParameters($methods = array()) |
|
502 | 502 | { |
503 | - foreach($methods as $method=>$parameter) |
|
503 | + foreach ($methods as $method=>$parameter) |
|
504 | 504 | { |
505 | 505 | $this->methodParameters[$method] = $parameter; |
506 | 506 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | ''.$this->getAccessibleMethodValue($method).' function '.$method.'\(\)' => ''.$this->getAccessibleMethodValue($method).' function '.$method.'('.$parameter.')' |
510 | 510 | |
511 | - ],$this->file,true); |
|
511 | + ], $this->file, true); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | */ |
520 | 520 | public function createPath() |
521 | 521 | { |
522 | - if(!file_exists($this->path)){ |
|
523 | - if(!$this->fileSystem->makeDirectory($this->path)){ |
|
522 | + if (!file_exists($this->path)) { |
|
523 | + if (!$this->fileSystem->makeDirectory($this->path)) { |
|
524 | 524 | throw new \Error($this->path.' makeDirectory fail'); |
525 | 525 | } |
526 | 526 | } |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public function getClassInstance() |
548 | 548 | { |
549 | - if(!isset($this->loaded['createClass'])){ |
|
549 | + if (!isset($this->loaded['createClass'])) { |
|
550 | 550 | |
551 | - if(is_null(self::$instance)){ |
|
551 | + if (is_null(self::$instance)) { |
|
552 | 552 | $class = Utils::getNamespace($this->file); |
553 | 553 | self::$instance = new $class; |
554 | 554 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | */ |
567 | 567 | public function getClassString() |
568 | 568 | { |
569 | - if(preg_match('@class\s.*\n{@',$this->fileSystem->get($this->file),$parse)){ |
|
569 | + if (preg_match('@class\s.*\n{@', $this->fileSystem->get($this->file), $parse)) { |
|
570 | 570 | return $parse[0]; |
571 | 571 | } |
572 | 572 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @param bool $regexEscape |
581 | 581 | * @return mixed|string |
582 | 582 | */ |
583 | - private function getMethodParameters($method,$regexEscape=true) |
|
583 | + private function getMethodParameters($method, $regexEscape = true) |
|
584 | 584 | { |
585 | 585 | return (isset($this->methodParameters[$method])) ? |
586 | 586 | ($regexEscape) ? $this->regexEscape($this->methodParameters[$method]) : $this->methodParameters[$method] |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | { |
597 | 597 | $stubFile = $this->stubPath.''.DIRECTORY_SEPARATOR.''.$this->type.'.stub'; |
598 | 598 | |
599 | - if(!file_exists($stubFile)){ |
|
599 | + if (!file_exists($stubFile)) { |
|
600 | 600 | throw new \Error($stubFile.' path is not available'); |
601 | 601 | } |
602 | 602 | |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function regexEscape($data) |
613 | 613 | { |
614 | - $dataEscape = str_replace('\\','\\\\',$data); |
|
615 | - $dataEscape = str_replace('$','\$',$dataEscape); |
|
616 | - $dataEscape = str_replace('()','\(\)',$dataEscape); |
|
617 | - $dataEscape = str_replace('[]','\[\]',$dataEscape); |
|
614 | + $dataEscape = str_replace('\\', '\\\\', $data); |
|
615 | + $dataEscape = str_replace('$', '\$', $dataEscape); |
|
616 | + $dataEscape = str_replace('()', '\(\)', $dataEscape); |
|
617 | + $dataEscape = str_replace('[]', '\[\]', $dataEscape); |
|
618 | 618 | |
619 | 619 | |
620 | 620 | return $dataEscape; |
@@ -630,24 +630,24 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @throws FileNotFoundException |
632 | 632 | */ |
633 | - private function replaceFileContent($replacement,$file,$default=false) |
|
633 | + private function replaceFileContent($replacement, $file, $default = false) |
|
634 | 634 | { |
635 | 635 | $replacementVariables = ($default) ? $replacement : $this->replacementVariables($replacement); |
636 | 636 | $content = $this->fileSystem->get($file); |
637 | 637 | |
638 | - foreach ($replacementVariables as $key=>$replacementVariable){ |
|
638 | + foreach ($replacementVariables as $key=>$replacementVariable) { |
|
639 | 639 | |
640 | - if($default){ |
|
640 | + if ($default) { |
|
641 | 641 | $search = '/'.$key.'/'; |
642 | 642 | } |
643 | - else{ |
|
643 | + else { |
|
644 | 644 | $search = '/__'.$key.'__/'; |
645 | 645 | } |
646 | 646 | |
647 | 647 | $replace = $replacementVariable; |
648 | - $content = preg_replace($search,$replace,$content); |
|
648 | + $content = preg_replace($search, $replace, $content); |
|
649 | 649 | } |
650 | - $this->fileSystem->replace($file,$content); |
|
650 | + $this->fileSystem->replace($file, $content); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -656,12 +656,12 @@ discard block |
||
656 | 656 | * @param array $replacement |
657 | 657 | * @return array |
658 | 658 | */ |
659 | - private function replacementVariables($replacement=array()) |
|
659 | + private function replacementVariables($replacement = array()) |
|
660 | 660 | { |
661 | 661 | $replacement['namespace'] = $this->namespace; |
662 | 662 | $replacement['class'] = $this->name; |
663 | 663 | |
664 | - return array_map(function($item){ |
|
664 | + return array_map(function($item) { |
|
665 | 665 | return ucfirst($item); |
666 | 666 | },$replacement); |
667 | 667 | } |
@@ -671,12 +671,12 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @param $stubPath |
673 | 673 | */ |
674 | - public function setStubPath($stubPath=null) |
|
674 | + public function setStubPath($stubPath = null) |
|
675 | 675 | { |
676 | - if(is_null($stubPath)){ |
|
676 | + if (is_null($stubPath)) { |
|
677 | 677 | $this->stubPath = app()->corePath().'Console/Stubs/generator'; |
678 | 678 | } |
679 | - else{ |
|
679 | + else { |
|
680 | 680 | $this->stubPath = $stubPath; |
681 | 681 | } |
682 | 682 | } |
@@ -184,8 +184,7 @@ discard block |
||
184 | 184 | 'class\s.*\n{' =>'class '.$className.' extends '.$alias.' '.$implements.' |
185 | 185 | {' |
186 | 186 | ],$this->file,true); |
187 | - } |
|
188 | - else{ |
|
187 | + } else{ |
|
189 | 188 | |
190 | 189 | $this->replaceFileContent([ |
191 | 190 | 'class\s.*\n{' =>'class '.$className.' extends '.$alias.' |
@@ -231,8 +230,7 @@ discard block |
||
231 | 230 | 'class\s.*\n{' =>'class '.$className.' extends '.$extendsAliasName.' implements '.implode(',',$implementList).' |
232 | 231 | {' |
233 | 232 | ],$this->file,true); |
234 | - } |
|
235 | - elseif(in_array('extends',$statements) && in_array('implements',$statements)){ |
|
233 | + } elseif(in_array('extends',$statements) && in_array('implements',$statements)){ |
|
236 | 234 | |
237 | 235 | $extendsAliasName = $statements[array_search('extends',$statements)+1]; |
238 | 236 | |
@@ -240,15 +238,13 @@ discard block |
||
240 | 238 | 'class\s.*\n{' =>'class '.$className.' extends '.$extendsAliasName.' implements '.end($statements).','.implode(',',$implementList).' |
241 | 239 | {' |
242 | 240 | ],$this->file,true); |
243 | - } |
|
244 | - elseif(!in_array('extends',$statements) && in_array('implements',$statements)){ |
|
241 | + } elseif(!in_array('extends',$statements) && in_array('implements',$statements)){ |
|
245 | 242 | |
246 | 243 | $this->replaceFileContent([ |
247 | 244 | 'class\s.*\n{' =>'class '.$className.' implements '.end($statements).','.implode(',',$implementList).' |
248 | 245 | {' |
249 | 246 | ],$this->file,true); |
250 | - } |
|
251 | - else{ |
|
247 | + } else{ |
|
252 | 248 | |
253 | 249 | $this->replaceFileContent([ |
254 | 250 | 'class\s.*\n{' =>'class '.$className.' implements '.implode(',',$implementList).' |
@@ -639,8 +635,7 @@ discard block |
||
639 | 635 | |
640 | 636 | if($default){ |
641 | 637 | $search = '/'.$key.'/'; |
642 | - } |
|
643 | - else{ |
|
638 | + } else{ |
|
644 | 639 | $search = '/__'.$key.'__/'; |
645 | 640 | } |
646 | 641 | |
@@ -675,8 +670,7 @@ discard block |
||
675 | 670 | { |
676 | 671 | if(is_null($stubPath)){ |
677 | 672 | $this->stubPath = app()->corePath().'Console/Stubs/generator'; |
678 | - } |
|
679 | - else{ |
|
673 | + } else{ |
|
680 | 674 | $this->stubPath = $stubPath; |
681 | 675 | } |
682 | 676 | } |