Passed
Push — master ( 74ddc4...4602de )
by Mohammad
03:46
created
src/Commands/Generator.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function handle()
62 62
     {
63
-        $file = preg_split( " (/|\\\\) ", (string)$this->argument('name')) ?? [];
63
+        $file = preg_split(" (/|\\\\) ", (string) $this->argument('name')) ?? [];
64 64
         $this->repoName = $file[count($file) - 1];
65 65
 
66 66
         unset($file[count($file) - 1]);
67 67
         $path = implode("\\", $file);
68 68
 
69
-        if($this->option('only-view'))
69
+        if ($this->option('only-view'))
70 70
         {
71 71
             $this->makeViewsAndLanguage($path);
72 72
             return null;
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 
78 78
     function makeRepositoryPatternFiles($path)
79 79
     {
80
-        $model= str_plural(\Config::get('repository.model'));
81
-        $interface= str_plural(\Config::get('repository.interface'));
82
-        $repository= str_plural(\Config::get('repository.repository'));
80
+        $model = str_plural(\Config::get('repository.model'));
81
+        $interface = str_plural(\Config::get('repository.interface'));
82
+        $repository = str_plural(\Config::get('repository.repository'));
83 83
 
84 84
         $this->generate($path, \Config::get('repository.controllers_folder'), 'Controller');
85 85
         $this->generate($path, $model, 'Entity');
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $this->generate($path, $interface, 'Interface');
88 88
         $this->generate($path, $repository, 'Repository');
89 89
 
90
-        File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '".$path."\\".$this->repoName."Controller');");
90
+        File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '" . $path . "\\" . $this->repoName . "Controller');");
91 91
     }
92 92
 
93 93
     /**
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 
101 101
         $createHtml = '';
102 102
         $editHtml = '';
103
-        if($entity instanceof Model)
103
+        if ($entity instanceof Model)
104 104
         {
105 105
             $createHtml = $this->formGenerator->generateForm($entity);
106
-            $editHtml = $this->formGenerator->generateForm($entity,'put');
106
+            $editHtml = $this->formGenerator->generateForm($entity, 'put');
107 107
         }
108 108
         else
109 109
         {
110
-            if(!$this->confirm('There is no entity for '.$this->repoName.", do you want to continue (this will disable form generator) ?"))
110
+            if (!$this->confirm('There is no entity for ' . $this->repoName . ", do you want to continue (this will disable form generator) ?"))
111 111
             {
112 112
                 echo "Dispatch ..";
113 113
                 die;
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 
117 117
         foreach (\Config::get('repository.languages') as $lang)
118 118
         {
119
-            $this->generate(lcfirst($this->repoName),\Config::get('repository.lang_path')."/{$lang}" , 'lang');
119
+            $this->generate(lcfirst($this->repoName), \Config::get('repository.lang_path') . "/{$lang}", 'lang');
120 120
         }
121
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'create',$createHtml);
122
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'edit',$editHtml);
123
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'index');
124
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'show');
121
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'create', $createHtml);
122
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'edit', $editHtml);
123
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'index');
124
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'show');
125 125
     }
126 126
 
127 127
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      */
132 132
     function getEntity($path)
133 133
     {
134
-        $myClass = 'App\Entities\\'.$path."\\".$this->repoName;
135
-        if(!class_exists($myClass))
134
+        $myClass = 'App\Entities\\' . $path . "\\" . $this->repoName;
135
+        if (!class_exists($myClass))
136 136
             return false;
137 137
 
138 138
         $refl = new ReflectionClass($myClass);
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
      * @param string $form
159 159
      * @return bool
160 160
      */
161
-    protected function generate($path, $folder, $type,$form ='')
161
+    protected function generate($path, $folder, $type, $form = '')
162 162
     {
163 163
         $content = $this->getStub($type);
164 164
 
165
-        if($content === false)
165
+        if ($content === false)
166 166
         {
167
-            echo 'file '.$type.".stub is not exist !";
167
+            echo 'file ' . $type . ".stub is not exist !";
168 168
             return false;
169 169
         }
170 170
 
@@ -181,21 +181,21 @@  discard block
 block discarded – undo
181 181
                 $this->repoName,
182 182
                 str_plural($folder),
183 183
                 $path,
184
-                str_plural(\Config::get('repository.model','Entity')),
185
-                str_plural(\Config::get('repository.interface','Interface')),
184
+                str_plural(\Config::get('repository.model', 'Entity')),
185
+                str_plural(\Config::get('repository.interface', 'Interface')),
186 186
                 $form
187 187
             ],
188 188
             $this->getStub($type)
189 189
         );
190 190
 
191
-        $folder = str_replace('\\','/',$folder);
192
-        $path = str_replace('\\','/',$path);
191
+        $folder = str_replace('\\', '/', $folder);
192
+        $path = str_replace('\\', '/', $path);
193 193
         
194 194
         switch ($type)
195 195
         {
196 196
             case 'Entity':
197 197
                 $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}");
198
-                $filePath = rtrim($filePath,'/');
198
+                $filePath = rtrim($filePath, '/');
199 199
                 $filePath .= "/";
200 200
                 file_put_contents($filePath . "{$this->repoName}.php", $template);
201 201
                 break;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             case 'Repository':
205 205
             case 'Interface':
206 206
                 $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}");
207
-                $filePath = rtrim($filePath,'/');
207
+                $filePath = rtrim($filePath, '/');
208 208
                 $filePath .= "/";
209 209
                 file_put_contents($filePath . "{$this->repoName}{$type}.php", $template);
210 210
                 break;
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
             case 'edit':
213 213
             case 'index':
214 214
             case 'show':
215
-                $filePath = $this->getFolderOrCreate($folder."/".str_plural($path))."/";
215
+                $filePath = $this->getFolderOrCreate($folder . "/" . str_plural($path)) . "/";
216 216
                 $repoName = lcfirst($type);
217
-                file_put_contents($filePath . $repoName.".blade.php", $template);
217
+                file_put_contents($filePath . $repoName . ".blade.php", $template);
218 218
             break;
219 219
             default:
220
-                $filePath = $this->getFolderOrCreate($folder)."/";
220
+                $filePath = $this->getFolderOrCreate($folder) . "/";
221 221
                 $repoName = lcfirst($this->repoName);
222
-                file_put_contents($filePath . $repoName.".php", $template);
222
+                file_put_contents($filePath . $repoName . ".php", $template);
223 223
         }
224 224
         return true;
225 225
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@  discard block
 block discarded – undo
104 104
         {
105 105
             $createHtml = $this->formGenerator->generateForm($entity);
106 106
             $editHtml = $this->formGenerator->generateForm($entity,'put');
107
-        }
108
-        else
107
+        } else
109 108
         {
110 109
             if(!$this->confirm('There is no entity for '.$this->repoName.", do you want to continue (this will disable form generator) ?"))
111 110
             {
@@ -132,8 +131,9 @@  discard block
 block discarded – undo
132 131
     function getEntity($path)
133 132
     {
134 133
         $myClass = 'App\Entities\\'.$path."\\".$this->repoName;
135
-        if(!class_exists($myClass))
136
-            return false;
134
+        if(!class_exists($myClass)) {
135
+                    return false;
136
+        }
137 137
 
138 138
         $refl = new ReflectionClass($myClass);
139 139
 
Please login to merge, or discard this patch.