@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @var $type |
20 | 20 | */ |
21 | - public $type='controller'; |
|
21 | + public $type = 'controller'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @var array |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var array |
39 | 39 | */ |
40 | - protected $commandRule=[ |
|
40 | + protected $commandRule = [ |
|
41 | 41 | 'create' => ['controller'], |
42 | - 'rename' => ['controller','rename'], |
|
42 | + 'rename' => ['controller', 'rename'], |
|
43 | 43 | 'all' => [], |
44 | 44 | ]; |
45 | 45 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $this->argument['bundleName'] = $controller.''.StaticPathList::$controllerBundleName; |
57 | 57 | |
58 | - if(!file_exists(app()->path()->controller())){ |
|
58 | + if (!file_exists(app()->path()->controller())) { |
|
59 | 59 | $this->directory['createController'] = app()->path()->controller(); |
60 | 60 | } |
61 | 61 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $fullNamespaceForController = $this->argument['controllerNamespace'].'\\'.$this->argument['serviceClass'].''.$this->argument['callClassPrefix']; |
75 | 75 | |
76 | - $this->directory['routes'] = path()->route(); |
|
76 | + $this->directory['routes'] = path()->route(); |
|
77 | 77 | |
78 | 78 | $routePath = $this->directory['routes'].''.DIRECTORY_SEPARATOR.''.$controller.'Route.php'; |
79 | 79 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | // we get to the service directory, which is called the controller. |
82 | 82 | $this->file->makeDirectory($this); |
83 | 83 | |
84 | - if(isset($this->argument['resource']) && file_exists($this->directory['endpoint'])){ |
|
84 | + if (isset($this->argument['resource']) && file_exists($this->directory['endpoint'])) { |
|
85 | 85 | |
86 | - $this->touch['service/resource'] = $this->directory['resource'].''.DIRECTORY_SEPARATOR.''.$this->argument['resource'].'.php'; |
|
86 | + $this->touch['service/resource'] = $this->directory['resource'].''.DIRECTORY_SEPARATOR.''.$this->argument['resource'].'.php'; |
|
87 | 87 | |
88 | 88 | $this->file->touch($this); |
89 | 89 | |
@@ -91,33 +91,33 @@ discard block |
||
91 | 91 | echo $this->classical(' > Resource Controller called as "'.$this->argument['resource'].'" has been successfully created in the '.$this->directory['resource'].''); |
92 | 92 | |
93 | 93 | } |
94 | - elseif(isset($this->argument['file']) && file_exists($this->directory['endpoint'])){ |
|
94 | + elseif (isset($this->argument['file']) && file_exists($this->directory['endpoint'])) { |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - if(isset($this->argument['type']) && $this->argument['type']=='Crud'){ |
|
98 | + if (isset($this->argument['type']) && $this->argument['type']=='Crud') { |
|
99 | 99 | |
100 | - $this->touch['service/controllerfilecrud'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['file'].''. $this->argument['callClassPrefix'].'.php'; |
|
100 | + $this->touch['service/controllerfilecrud'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['file'].''.$this->argument['callClassPrefix'].'.php'; |
|
101 | 101 | |
102 | - $this->file->touch($this,[ |
|
102 | + $this->file->touch($this, [ |
|
103 | 103 | 'stub'=>'Controller_Create' |
104 | 104 | ]); |
105 | 105 | |
106 | - files()->append($routePath,PHP_EOL.'Route::namespace(\''.$controller.'\')->get("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@get");'); |
|
107 | - files()->append($routePath,PHP_EOL.'Route::namespace(\''.$controller.'\')->post("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@create");'); |
|
108 | - files()->append($routePath,PHP_EOL.'Route::namespace(\''.$controller.'\')->put("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@update");'); |
|
109 | - files()->append($routePath,PHP_EOL.'Route::namespace(\''.$controller.'\')->delete("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@delete");'); |
|
106 | + files()->append($routePath, PHP_EOL.'Route::namespace(\''.$controller.'\')->get("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@get");'); |
|
107 | + files()->append($routePath, PHP_EOL.'Route::namespace(\''.$controller.'\')->post("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@create");'); |
|
108 | + files()->append($routePath, PHP_EOL.'Route::namespace(\''.$controller.'\')->put("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@update");'); |
|
109 | + files()->append($routePath, PHP_EOL.'Route::namespace(\''.$controller.'\')->delete("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@delete");'); |
|
110 | 110 | |
111 | 111 | } |
112 | - else{ |
|
112 | + else { |
|
113 | 113 | |
114 | - $this->touch['service/controllerfile'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['file'].''. $this->argument['callClassPrefix'].'.php'; |
|
114 | + $this->touch['service/controllerfile'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['file'].''.$this->argument['callClassPrefix'].'.php'; |
|
115 | 115 | |
116 | - $this->file->touch($this,[ |
|
116 | + $this->file->touch($this, [ |
|
117 | 117 | 'stub'=>'Controller_Create' |
118 | 118 | ]); |
119 | 119 | |
120 | - files()->append($routePath,PHP_EOL.'Route::namespace(\''.$controller.'\')->get("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@index");'); |
|
120 | + files()->append($routePath, PHP_EOL.'Route::namespace(\''.$controller.'\')->get("/'.strtolower($this->argument['file']).'","'.$this->argument['file'].'Controller@index");'); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | echo $this->classical(' > Controller called as "'.$this->argument['file'].'" has been successfully created in the '.$this->directory['endpoint'].''); |
128 | 128 | |
129 | 129 | } |
130 | - else{ |
|
130 | + else { |
|
131 | 131 | |
132 | 132 | // we process the processes related to file creation operations. |
133 | 133 | // and then create files related to the touch method of the file object as it is in the directory process. |
134 | 134 | |
135 | - if(isset($this->argument['type']) && $this->argument['type']=='Crud'){ |
|
136 | - $this->touch['service/endpointcrud'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['serviceClass'].''. $this->argument['callClassPrefix'].'.php'; |
|
135 | + if (isset($this->argument['type']) && $this->argument['type']=='Crud') { |
|
136 | + $this->touch['service/endpointcrud'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['serviceClass'].''.$this->argument['callClassPrefix'].'.php'; |
|
137 | 137 | $this->touch['service/routecrud'] = $routePath; |
138 | 138 | |
139 | 139 | } |
140 | - else{ |
|
141 | - $this->touch['service/endpoint'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['serviceClass'].''. $this->argument['callClassPrefix'].'.php'; |
|
140 | + else { |
|
141 | + $this->touch['service/endpoint'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.''.$this->argument['serviceClass'].''.$this->argument['callClassPrefix'].'.php'; |
|
142 | 142 | $this->touch['service/route'] = $routePath; |
143 | 143 | |
144 | 144 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | $this->touch['service/dummy'] = $this->directory['configuration'].''.DIRECTORY_SEPARATOR.'Dummy.yaml'; |
151 | 151 | $this->touch['service/doc'] = $this->directory['configuration'].''.DIRECTORY_SEPARATOR.'Doc.yaml'; |
152 | 152 | $this->touch['service/readme'] = $this->directory['endpoint'].''.DIRECTORY_SEPARATOR.'README.md'; |
153 | - $this->touch['service/policy'] = $this->directory['policy'].''.DIRECTORY_SEPARATOR.''.$this->argument['serviceClass'].''. $this->argument['callClassPrefix'].'Policy.php'; |
|
153 | + $this->touch['service/policy'] = $this->directory['policy'].''.DIRECTORY_SEPARATOR.''.$this->argument['serviceClass'].''.$this->argument['callClassPrefix'].'Policy.php'; |
|
154 | 154 | |
155 | - $this->file->touch($this,[ |
|
155 | + $this->file->touch($this, [ |
|
156 | 156 | 'stub'=>'Controller_Create' |
157 | 157 | ]); |
158 | 158 | |
@@ -176,24 +176,24 @@ discard block |
||
176 | 176 | { |
177 | 177 | $path = path()->controller().'/'.$this->argument['controller'].''.StaticPathList::$controllerBundleName; |
178 | 178 | |
179 | - if(file_exists($path)){ |
|
179 | + if (file_exists($path)) { |
|
180 | 180 | |
181 | - $newPathName = str_replace($this->argument['controller'],$this->argument['rename'],$path); |
|
181 | + $newPathName = str_replace($this->argument['controller'], $this->argument['rename'], $path); |
|
182 | 182 | |
183 | 183 | |
184 | - rename($path,$newPathName); |
|
184 | + rename($path, $newPathName); |
|
185 | 185 | |
186 | 186 | $getAllFiles = files()->getAllFilesInDirectory($newPathName); |
187 | 187 | |
188 | - $getPathWithPhpExtensions = Utils::getPathWithPhpExtension($getAllFiles,$newPathName); |
|
188 | + $getPathWithPhpExtensions = Utils::getPathWithPhpExtension($getAllFiles, $newPathName); |
|
189 | 189 | |
190 | - foreach ($getPathWithPhpExtensions as $getPathWithPhpExtension){ |
|
190 | + foreach ($getPathWithPhpExtensions as $getPathWithPhpExtension) { |
|
191 | 191 | |
192 | - $withoutFullPath = str_replace($newPathName,"",$getPathWithPhpExtension); |
|
192 | + $withoutFullPath = str_replace($newPathName, "", $getPathWithPhpExtension); |
|
193 | 193 | |
194 | 194 | $newName = $newPathName."".preg_replace("((.*)".$this->argument['controller'].")", "$1".$this->argument['rename'], $withoutFullPath); |
195 | 195 | |
196 | - rename($getPathWithPhpExtension,$newName); |
|
196 | + rename($getPathWithPhpExtension, $newName); |
|
197 | 197 | |
198 | 198 | Utils::changeClass($newName, |
199 | 199 | [ |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | private function docUpdate() |
214 | 214 | { |
215 | - $docPath = $this->directory['configuration'] .'/Doc.yaml'; |
|
215 | + $docPath = $this->directory['configuration'].'/Doc.yaml'; |
|
216 | 216 | |
217 | 217 | $doc = Utils::yaml($docPath); |
218 | 218 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * @var array |
27 | 27 | */ |
28 | - protected $stubList=array(); |
|
28 | + protected $stubList = array(); |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * FileProcess constructor. |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | * @param $data |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function dumpFile($file,$data) |
|
44 | + public function dumpFile($file, $data) |
|
45 | 45 | { |
46 | 46 | try { |
47 | - $this->fs->dumpFile($file,$data); |
|
47 | + $this->fs->dumpFile($file, $data); |
|
48 | 48 | return true; |
49 | 49 | } catch (IOExceptionInterface $exception) { |
50 | 50 | return false; |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | * @param bool $status |
57 | 57 | * @return mixed |
58 | 58 | */ |
59 | - public function makeDirectory($data,$status=false) |
|
59 | + public function makeDirectory($data, $status = false) |
|
60 | 60 | { |
61 | - if($data->type=="project" && file_exists($data->project)){ |
|
61 | + if ($data->type=="project" && file_exists($data->project)) { |
|
62 | 62 | throw new \LogicException('This Project Is Already Available'); |
63 | 63 | } |
64 | - if(false===$status){ |
|
64 | + if (false===$status) { |
|
65 | 65 | |
66 | - if($data->type!=="project" && !file_exists($data->project)){ |
|
66 | + if ($data->type!=="project" && !file_exists($data->project)) { |
|
67 | 67 | throw new \LogicException('Project No'); |
68 | 68 | } |
69 | 69 | } |
70 | - foreach ($data->directory as $directory){ |
|
70 | + foreach ($data->directory as $directory) { |
|
71 | 71 | try { |
72 | - $this->fs->mkdir($directory,'0777'); |
|
73 | - chmod($directory,0777); |
|
72 | + $this->fs->mkdir($directory, '0777'); |
|
73 | + chmod($directory, 0777); |
|
74 | 74 | } catch (IOExceptionInterface $e) { |
75 | 75 | return "An error occurred while creating your directory at ".$e->getPath(); |
76 | 76 | } |
@@ -102,25 +102,25 @@ discard block |
||
102 | 102 | * @param $data |
103 | 103 | * @param array $complex |
104 | 104 | */ |
105 | - public function touch($data,$complex=array()) |
|
105 | + public function touch($data, $complex = array()) |
|
106 | 106 | { |
107 | - $this->data=$data; |
|
107 | + $this->data = $data; |
|
108 | 108 | |
109 | - if(isset($complex['stub']) && isset($this->data->argument['stub'])){ |
|
109 | + if (isset($complex['stub']) && isset($this->data->argument['stub'])) { |
|
110 | 110 | |
111 | 111 | $this->stubManager($complex); |
112 | 112 | } |
113 | 113 | |
114 | - $execArray=(count($this->stubList)) ? $this->stubList : $this->data->touch; |
|
114 | + $execArray = (count($this->stubList)) ? $this->stubList : $this->data->touch; |
|
115 | 115 | |
116 | - foreach ($execArray as $execution=>$touch){ |
|
116 | + foreach ($execArray as $execution=>$touch) { |
|
117 | 117 | |
118 | - if(!file_exists($touch) && $touch!==null){ |
|
118 | + if (!file_exists($touch) && $touch!==null) { |
|
119 | 119 | touch($touch); |
120 | 120 | |
121 | - $executionPath=$this->stubPath.'/'.$execution.'.stub'; |
|
122 | - if(file_exists($executionPath)){ |
|
123 | - $this->fopenprocess($executionPath,$touch,$data); |
|
121 | + $executionPath = $this->stubPath.'/'.$execution.'.stub'; |
|
122 | + if (file_exists($executionPath)) { |
|
123 | + $this->fopenprocess($executionPath, $touch, $data); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -129,37 +129,37 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * @param array $complex |
131 | 131 | */ |
132 | - private function stubManager($complex=array()) |
|
132 | + private function stubManager($complex = array()) |
|
133 | 133 | { |
134 | - $stubStructure = explode("_",$complex['stub']); |
|
134 | + $stubStructure = explode("_", $complex['stub']); |
|
135 | 135 | $stubStructure[] = $this->data->argument['stub']; |
136 | 136 | |
137 | - $stubberDirectoryList=path()->stubs(); |
|
137 | + $stubberDirectoryList = path()->stubs(); |
|
138 | 138 | |
139 | - foreach ($stubStructure as $stubberDirectory){ |
|
139 | + foreach ($stubStructure as $stubberDirectory) { |
|
140 | 140 | |
141 | 141 | $stubberDirectoryList = $stubberDirectoryList.'/'.$stubberDirectory; |
142 | 142 | |
143 | 143 | $this->setDirectory($stubberDirectoryList); |
144 | 144 | } |
145 | 145 | |
146 | - foreach ($this->data->touch as $execution=>$executionFile){ |
|
146 | + foreach ($this->data->touch as $execution=>$executionFile) { |
|
147 | 147 | |
148 | - $executionArray=explode("/",$execution); |
|
148 | + $executionArray = explode("/", $execution); |
|
149 | 149 | |
150 | 150 | $executionStub = end($executionArray).''; |
151 | 151 | $this->stubList[$executionStub] = $executionFile; |
152 | 152 | $stubberFile = $stubberDirectoryList.'/'.$executionStub.'.stub'; |
153 | 153 | |
154 | - $originalPath=$this->stubPath.'/'.$execution.'.stub'; |
|
154 | + $originalPath = $this->stubPath.'/'.$execution.'.stub'; |
|
155 | 155 | |
156 | - if(!file_exists($stubberFile)){ |
|
156 | + if (!file_exists($stubberFile)) { |
|
157 | 157 | |
158 | - $this->fs->copy($originalPath,$stubberFile); |
|
158 | + $this->fs->copy($originalPath, $stubberFile); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - $this->stubPath=$stubberDirectoryList; |
|
162 | + $this->stubPath = $stubberDirectoryList; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | * @param $param |
170 | 170 | * @return bool |
171 | 171 | */ |
172 | - public function fopenprocess($executionPath,$path,$param) |
|
172 | + public function fopenprocess($executionPath, $path, $param) |
|
173 | 173 | { |
174 | 174 | $dt = fopen($executionPath, "r"); |
175 | 175 | $content = fread($dt, filesize($executionPath)); |
176 | 176 | fclose($dt); |
177 | 177 | |
178 | - foreach ($param->argument as $key=>$value){ |
|
178 | + foreach ($param->argument as $key=>$value) { |
|
179 | 179 | |
180 | - $content=str_replace("__".$key."__",$value,$content); |
|
181 | - $content=str_replace("__".$key."-low__",strtolower($value),$content); |
|
180 | + $content = str_replace("__".$key."__", $value, $content); |
|
181 | + $content = str_replace("__".$key."-low__", strtolower($value), $content); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $dt = fopen($path, "w"); |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * @param $param |
195 | 195 | * @return bool |
196 | 196 | */ |
197 | - public function stubCopy($executionPath,$path,$param) |
|
197 | + public function stubCopy($executionPath, $path, $param) |
|
198 | 198 | { |
199 | 199 | $dt = fopen($executionPath, "r"); |
200 | 200 | $content = fread($dt, filesize($executionPath)); |
201 | 201 | fclose($dt); |
202 | 202 | |
203 | - foreach ($param->argument as $key=>$value){ |
|
204 | - $content=str_replace("__".$key."__",$value,$content); |
|
203 | + foreach ($param->argument as $key=>$value) { |
|
204 | + $content = str_replace("__".$key."__", $value, $content); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $dt = fopen($path, "w"); |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @param null $file |
216 | 216 | * @return mixed|null |
217 | 217 | */ |
218 | - public function callFile($file=null) |
|
218 | + public function callFile($file = null) |
|
219 | 219 | { |
220 | - if(file_exists($file)){ |
|
220 | + if (file_exists($file)) { |
|
221 | 221 | return require_once($file); |
222 | 222 | } |
223 | 223 | return null; |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | * @param null|string $file |
230 | 230 | * @param null|string $data |
231 | 231 | */ |
232 | - public function writeFile($file=null,$data=null) |
|
232 | + public function writeFile($file = null, $data = null) |
|
233 | 233 | { |
234 | - if(!is_null($file) && !is_null($data)){ |
|
234 | + if (!is_null($file) && !is_null($data)) { |
|
235 | 235 | |
236 | 236 | $dt = fopen($file, "r"); |
237 | 237 | $content = fread($dt, filesize($file)); |