@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param null $path |
47 | 47 | * @param null $fileSystem |
48 | 48 | */ |
49 | - public function __construct($path=null,$fileSystem=null) |
|
49 | + public function __construct($path = null, $fileSystem = null) |
|
50 | 50 | { |
51 | 51 | $this->path = $path; |
52 | 52 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function createPath() |
66 | 66 | { |
67 | - if(!file_exists($this->path)){ |
|
68 | - if(!$this->fileSystem->makeDirectory($this->path)){ |
|
67 | + if (!file_exists($this->path)) { |
|
68 | + if (!$this->fileSystem->makeDirectory($this->path)) { |
|
69 | 69 | throw new \Error($this->path.' makeDirectory fail'); |
70 | 70 | } |
71 | 71 | } |
@@ -81,16 +81,16 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @throws FileNotFoundException |
83 | 83 | */ |
84 | - public function createFile($name=null,$replacement=array()) |
|
84 | + public function createFile($name = null, $replacement = array()) |
|
85 | 85 | { |
86 | - if(file_exists($this->path) && !is_null($name)){ |
|
86 | + if (file_exists($this->path) && !is_null($name)) { |
|
87 | 87 | |
88 | 88 | $content = $this->fileSystem->get($this->getStubFile()); |
89 | 89 | $this->file = $this->path.''.DIRECTORY_SEPARATOR.''.ucfirst($name).'.php'; |
90 | 90 | |
91 | - if($this->fileSystem->put($this->file,$content)!==FALSE){ |
|
91 | + if ($this->fileSystem->put($this->file, $content)!==FALSE) { |
|
92 | 92 | $this->name = $name; |
93 | - $this->replaceFileContent($replacement,$this->file); |
|
93 | + $this->replaceFileContent($replacement, $this->file); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param array $params |
104 | 104 | */ |
105 | - public function createMethod($params=array()) |
|
105 | + public function createMethod($params = array()) |
|
106 | 106 | { |
107 | 107 | |
108 | 108 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $stubFile = $this->stubPath.''.DIRECTORY_SEPARATOR.''.$this->type.'.stub'; |
118 | 118 | |
119 | - if(!file_exists($stubFile)){ |
|
119 | + if (!file_exists($stubFile)) { |
|
120 | 120 | throw new \Error($stubFile.' path is not available'); |
121 | 121 | } |
122 | 122 | |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | * @param $file |
131 | 131 | * @return void |
132 | 132 | */ |
133 | - private function replaceFileContent($replacement,$file) |
|
133 | + private function replaceFileContent($replacement, $file) |
|
134 | 134 | { |
135 | 135 | $replacementVariables = $this->replacementVariables($replacement); |
136 | 136 | $content = $this->fileSystem->get($file); |
137 | 137 | |
138 | - foreach ($replacementVariables as $key=>$replacementVariable){ |
|
138 | + foreach ($replacementVariables as $key=>$replacementVariable) { |
|
139 | 139 | $search = '/__'.$key.'__/'; |
140 | 140 | $replace = $replacementVariable; |
141 | - $content = preg_replace($search,$replace,$content); |
|
141 | + $content = preg_replace($search, $replace, $content); |
|
142 | 142 | } |
143 | - $this->fileSystem->replace($file,$content); |
|
143 | + $this->fileSystem->replace($file, $content); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | * @param array $replacement |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - private function replacementVariables($replacement=array()) |
|
152 | + private function replacementVariables($replacement = array()) |
|
153 | 153 | { |
154 | 154 | $replacement['namespace'] = $this->namespace; |
155 | 155 | $replacement['class'] = $this->name; |
156 | 156 | |
157 | - return array_map(function($item){ |
|
157 | + return array_map(function($item) { |
|
158 | 158 | return ucfirst($item); |
159 | 159 | },$replacement); |
160 | 160 | } |