Passed
Push — master ( c354c0...c003b4 )
by Mohammad
03:37
created
src/Utility/Request.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     protected function failedValidation(Validator $validator)
30 30
     {
31 31
 
32
-        if (strpos($this->path(),'api') !== false) {
32
+        if (strpos($this->path(), 'api') !== false) {
33 33
             $errors = (new ValidationException($validator))->errors();
34 34
             throw new HttpResponseException(response()->json(['success' => false, 'errors' => $errors,
35 35
             ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         parent::failedValidation($validator);
38 38
     }
39 39
 
40
-    public function rules(){
41
-        \App::setLocale($this->header('Language','en'));
40
+    public function rules() {
41
+        \App::setLocale($this->header('Language', 'en'));
42 42
     }
43 43
 }
Please login to merge, or discard this patch.
src/RepositoryServiceProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
         parent::__construct($app);
36 36
 
37 37
         if ($this->app['config']->get('repository') === null) {
38
-            $this->app['config']->set('repository', require __DIR__.'/config/repository.php');
38
+            $this->app['config']->set('repository', require __DIR__ . '/config/repository.php');
39 39
         }
40
-        $interfaces= str_plural(Config::get('repository.interface'));
41
-        $repositories= str_plural(Config::get('repository.repository'));
42
-        $interface= Config::get('repository.interface');
43
-        $repository= Config::get('repository.repository');
40
+        $interfaces = str_plural(Config::get('repository.interface'));
41
+        $repositories = str_plural(Config::get('repository.repository'));
42
+        $interface = Config::get('repository.interface');
43
+        $repository = Config::get('repository.repository');
44 44
 
45
-        $contractsFolder = Config::get('repository.app_path').'/'.$interfaces;
45
+        $contractsFolder = Config::get('repository.app_path') . '/' . $interfaces;
46 46
 
47 47
         if ($contractsFolder) {
48 48
             $directory = new \RecursiveDirectoryIterator($contractsFolder);
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
             $regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);
51 51
             foreach ($regex as $name => $value) {
52 52
                 
53
-                $contract = strstr($name,'app/') ?: strstr($name,'app\\');
54
-                $contract = rtrim($contract,'.php');
53
+                $contract = strstr($name, 'app/') ?: strstr($name, 'app\\');
54
+                $contract = rtrim($contract, '.php');
55 55
                 
56 56
                 $contractName = str_replace('/', '\\', ucfirst($contract));
57 57
 
58 58
                 $repositoryClass = str_replace($interfaces, $repositories, $contractName);
59
-                $repositoryClass = str_replace([$interface,'Interface'], $repository, $repositoryClass);
59
+                $repositoryClass = str_replace([$interface, 'Interface'], $repository, $repositoryClass);
60 60
 
61 61
                 $this->providers[] = $contractName;
62 62
                 $this->bindings[$contractName] = $repositoryClass;
Please login to merge, or discard this patch.
src/Utility/AbstractRepository.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function filter($criteria = [])
79 79
     {
80
-        $criteria= $this->order($criteria);
80
+        $criteria = $this->order($criteria);
81 81
 
82 82
         /** @var Entity $latest */
83 83
         $latest = $this->model->with($this->with);
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 
88 88
         if (isset($criteria['search'])) {
89 89
             foreach ($this->model->searchable as $method => $columns) {
90
-                if(method_exists($this->model,$method))
90
+                if (method_exists($this->model, $method))
91 91
                 {
92
-                    $latest->orWhereHas($method,function ($query) use ($criteria,$columns)
92
+                    $latest->orWhereHas($method, function($query) use ($criteria, $columns)
93 93
                     {
94 94
                         /** @var $query Builder */
95
-                        $query->where(function ($query2) use($criteria,$columns){
95
+                        $query->where(function($query2) use($criteria, $columns){
96 96
                             /** @var $query2 Builder */
97 97
                             foreach ((array) $columns as $column)
98 98
                             {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @return array
126 126
      */
127
-    private function order($criteria=[]){
127
+    private function order($criteria = []) {
128 128
 
129 129
         if (isset($criteria['order'])) {
130 130
             $this->order = $criteria['order'];
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     {
172 172
         $item = $this->model->findOrFail($entityId);
173 173
 
174
-        if($item->update($attributes))
174
+        if ($item->update($attributes))
175 175
         {
176 176
             return $item;
177 177
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public function find($entityId = 0, $columns = ['*'])
236 236
     {
237
-        return $this->model->with($this->with)->find($entityId,$columns);
237
+        return $this->model->with($this->with)->find($entityId, $columns);
238 238
     }
239 239
 
240 240
     /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
     public function findOrFail($entityId = 0, $columns = ['*'])
247 247
     {
248
-        return $this->model->with($this->with)->findOrFail($entityId,$columns);
248
+        return $this->model->with($this->with)->findOrFail($entityId, $columns);
249 249
     }
250 250
     /**
251 251
      * @param array $filter
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,9 +100,9 @@
 block discarded – undo
100 100
                             }
101 101
                         });
102 102
                     });
103
+                } else {
104
+                                    $latest->orWhere($columns, 'like', "%" . $criteria['search'] . "%");
103 105
                 }
104
-                else
105
-                    $latest->orWhere($columns, 'like', "%" . $criteria['search'] . "%");
106 106
             }
107 107
         }
108 108
         unset($criteria['search']);
Please login to merge, or discard this patch.
src/Forms/Forms.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,6 +78,6 @@
 block discarded – undo
78 78
 
79 79
     function getFormStub($type)
80 80
     {
81
-        return file_get_contents(\Config::get('repository.stubs_path') . "/fields-".$type.".stub");
81
+        return file_get_contents(\Config::get('repository.stubs_path') . "/fields-" . $type . ".stub");
82 82
     }
83 83
 }
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
src/Forms/Input.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
     function template()
14 14
     {
15
-        $required=$this->column->getNotnull()?'required':'';
15
+        $required = $this->column->getNotnull() ? 'required' : '';
16 16
 
17 17
         $template = str_replace(
18 18
             [
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                 $this->column->getName(),
26 26
                 $this->getType(),
27 27
                 $required,
28
-                ucfirst(str_replace('_',' ',$this->column->getName()))
28
+                ucfirst(str_replace('_', ' ', $this->column->getName()))
29 29
             ],
30 30
             $this->getFormStub('input')
31 31
         );
Please login to merge, or discard this patch.
src/Forms/TextArea.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     function template()
15 15
     {
16
-        $required=$this->column->getNotnull()?'required':'';
16
+        $required = $this->column->getNotnull() ? 'required' : '';
17 17
 
18 18
         $template = str_replace(
19 19
             [
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 $this->column->getName(),
27 27
                 $this->getType(),
28 28
                 $required,
29
-                ucfirst(str_replace('_',' ',$this->column->getName()))
29
+                ucfirst(str_replace('_', ' ', $this->column->getName()))
30 30
             ],
31 31
             $this->getFormStub('textArea')
32 32
         );
Please login to merge, or discard this patch.
src/Commands/Generator.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -60,16 +60,16 @@  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
 
65
-        if(!$file) return "Something wrong with the inputs !";
65
+        if (!$file) return "Something wrong with the inputs !";
66 66
 
67 67
         $this->repoName = $file[count($file) - 1];
68 68
 
69 69
         unset($file[count($file) - 1]);
70 70
         $path = implode("\\", $file);
71 71
 
72
-        if($this->option('only-view'))
72
+        if ($this->option('only-view'))
73 73
         {
74 74
             $this->makeViewsAndLanguage($path);
75 75
             return null;
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
     function makeRepositoryPatternFiles($path)
82 82
     {
83
-        $model= str_plural(\Config::get('repository.model'));
84
-        $interface= str_plural(\Config::get('repository.interface'));
85
-        $repository= str_plural(\Config::get('repository.repository'));
83
+        $model = str_plural(\Config::get('repository.model'));
84
+        $interface = str_plural(\Config::get('repository.interface'));
85
+        $repository = str_plural(\Config::get('repository.repository'));
86 86
 
87 87
         $this->generate($path, \Config::get('repository.controllers_folder'), 'Controller');
88 88
         $this->generate($path, $model, 'Entity');
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $this->generate($path, $interface, 'Interface');
91 91
         $this->generate($path, $repository, 'Repository');
92 92
 
93
-        File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '".$path."\\".$this->repoName."Controller');");
93
+        File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '" . $path . "\\" . $this->repoName . "Controller');");
94 94
     }
95 95
 
96 96
     /**
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 
104 104
         $createHtml = '';
105 105
         $editHtml = '';
106
-        if($entity instanceof Model)
106
+        if ($entity instanceof Model)
107 107
         {
108 108
             $createHtml = $this->FormGenerator->generateForm($entity);
109
-            $editHtml = $this->FormGenerator->generateForm($entity,'put');
109
+            $editHtml = $this->FormGenerator->generateForm($entity, 'put');
110 110
         }
111 111
         else
112 112
         {
113
-            if(!$this->confirm('There is no entity for '.$this->repoName.", do you want to continue (this will disable form generator) ?"))
113
+            if (!$this->confirm('There is no entity for ' . $this->repoName . ", do you want to continue (this will disable form generator) ?"))
114 114
             {
115 115
                 echo "Dispatch ..";
116 116
                 die;
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 
120 120
         foreach (\Config::get('repository.languages') as $lang)
121 121
         {
122
-            $this->generate(lcfirst($this->repoName),\Config::get('repository.lang_path')."/{$lang}" , 'lang');
122
+            $this->generate(lcfirst($this->repoName), \Config::get('repository.lang_path') . "/{$lang}", 'lang');
123 123
         }
124
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'create',$createHtml);
125
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'edit',$editHtml);
126
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'index');
127
-        $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'show');
124
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'create', $createHtml);
125
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'edit', $editHtml);
126
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'index');
127
+        $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'show');
128 128
     }
129 129
 
130 130
     /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
      */
135 135
     function getEntity($path)
136 136
     {
137
-        $myClass = 'App\Entities\\'.$path."\\".$this->repoName;
138
-        if(!class_exists($myClass))
137
+        $myClass = 'App\Entities\\' . $path . "\\" . $this->repoName;
138
+        if (!class_exists($myClass))
139 139
             return false;
140 140
 
141 141
         $refl = new ReflectionClass($myClass);
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
      * @param string $form
162 162
      * @return bool
163 163
      */
164
-    protected function generate($path, $folder, $type,$form ='')
164
+    protected function generate($path, $folder, $type, $form = '')
165 165
     {
166 166
         $content = $this->getStub($type);
167 167
 
168
-        if($content === false)
168
+        if ($content === false)
169 169
         {
170
-            echo 'file '.$type.".stub is not exist !";
170
+            echo 'file ' . $type . ".stub is not exist !";
171 171
             return false;
172 172
         }
173 173
 
@@ -186,21 +186,21 @@  discard block
 block discarded – undo
186 186
                 str_plural(lcfirst($this->repoName)),
187 187
                 str_plural($folder),
188 188
                 $path,
189
-                str_plural(\Config::get('repository.model','Entity')),
190
-                str_plural(\Config::get('repository.interface','Interface')),
189
+                str_plural(\Config::get('repository.model', 'Entity')),
190
+                str_plural(\Config::get('repository.interface', 'Interface')),
191 191
                 $form
192 192
             ],
193 193
             $this->getStub($type)
194 194
         );
195 195
 
196
-        $folder = str_replace('\\','/',$folder);
197
-        $path = str_replace('\\','/',$path);
196
+        $folder = str_replace('\\', '/', $folder);
197
+        $path = str_replace('\\', '/', $path);
198 198
         
199 199
         switch ($type)
200 200
         {
201 201
             case 'Entity':
202 202
                 $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}");
203
-                $filePath = rtrim($filePath,'/');
203
+                $filePath = rtrim($filePath, '/');
204 204
                 $filePath .= "/";
205 205
                 file_put_contents($filePath . "{$this->repoName}.php", $template);
206 206
                 break;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             case 'Repository':
210 210
             case 'Interface':
211 211
                 $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}");
212
-                $filePath = rtrim($filePath,'/');
212
+                $filePath = rtrim($filePath, '/');
213 213
                 $filePath .= "/";
214 214
                 file_put_contents($filePath . "{$this->repoName}{$type}.php", $template);
215 215
                 break;
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
             case 'edit':
218 218
             case 'index':
219 219
             case 'show':
220
-                $filePath = $this->getFolderOrCreate($folder."/".str_plural($path))."/";
220
+                $filePath = $this->getFolderOrCreate($folder . "/" . str_plural($path)) . "/";
221 221
                 $repoName = lcfirst($type);
222
-                file_put_contents($filePath . $repoName.".blade.php", $template);
222
+                file_put_contents($filePath . $repoName . ".blade.php", $template);
223 223
             break;
224 224
             default:
225
-                $filePath = $this->getFolderOrCreate($folder)."/";
225
+                $filePath = $this->getFolderOrCreate($folder) . "/";
226 226
                 $repoName = lcfirst($this->repoName);
227
-                file_put_contents($filePath . $repoName.".php", $template);
227
+                file_put_contents($filePath . $repoName . ".php", $template);
228 228
         }
229 229
         return true;
230 230
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $file = preg_split( " (/|\\\\) ", (string)$this->argument('name')) ?? [];
64 64
 
65
-        if(!$file) return "Something wrong with the inputs !";
65
+        if(!$file) {
66
+            return "Something wrong with the inputs !";
67
+        }
66 68
 
67 69
         $this->repoName = $file[count($file) - 1];
68 70
 
@@ -107,8 +109,7 @@  discard block
 block discarded – undo
107 109
         {
108 110
             $createHtml = $this->FormGenerator->generateForm($entity);
109 111
             $editHtml = $this->FormGenerator->generateForm($entity,'put');
110
-        }
111
-        else
112
+        } else
112 113
         {
113 114
             if(!$this->confirm('There is no entity for '.$this->repoName.", do you want to continue (this will disable form generator) ?"))
114 115
             {
@@ -135,8 +136,9 @@  discard block
 block discarded – undo
135 136
     function getEntity($path)
136 137
     {
137 138
         $myClass = 'App\Entities\\'.$path."\\".$this->repoName;
138
-        if(!class_exists($myClass))
139
-            return false;
139
+        if(!class_exists($myClass)) {
140
+                    return false;
141
+        }
140 142
 
141 143
         $refl = new ReflectionClass($myClass);
142 144
 
Please login to merge, or discard this patch.
src/Forms/FormGenerator.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
      * @param string $method
72 72
      * @return string
73 73
      */
74
-    function generateForm($entity,$method = 'post')
74
+    function generateForm($entity, $method = 'post')
75 75
     {
76 76
         $html = '<form method="post" action="#">
77
-           <input type="hidden" name="__method" value="'.$method.'">';
77
+           <input type="hidden" name="__method" value="'.$method . '">';
78 78
         $html .= $this->getInputs($entity);
79 79
         $html .= '</form>';
80 80
         return $html;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     function getFillables($entity)
88 88
     {
89
-        if(!empty($entity->getFillable()))
89
+        if (!empty($entity->getFillable()))
90 90
             return $entity->getFillable();
91 91
 
92 92
         $columns = \Schema::getColumnListing($entity->getTable());
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     function getInputs($entity)
109 109
     {
110
-        if($this->inputs)
110
+        if ($this->inputs)
111 111
             return $this->inputs;
112 112
 
113 113
         return $this->generateInputs($entity);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $html = '';
123 123
         foreach ($this->getFillables($entity) as $fillable)
124 124
         {
125
-            $column = DB::connection()->getDoctrineColumn($entity->getTable(),$fillable);
125
+            $column = DB::connection()->getDoctrineColumn($entity->getTable(), $fillable);
126 126
 
127 127
             $html .= $this->generateFormInput($column);
128 128
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
      */
87 87
     function getFillables($entity)
88 88
     {
89
-        if(!empty($entity->getFillable()))
90
-            return $entity->getFillable();
89
+        if(!empty($entity->getFillable())) {
90
+                    return $entity->getFillable();
91
+        }
91 92
 
92 93
         $columns = \Schema::getColumnListing($entity->getTable());
93 94
 
@@ -107,8 +108,9 @@  discard block
 block discarded – undo
107 108
      */
108 109
     function getInputs($entity)
109 110
     {
110
-        if($this->inputs)
111
-            return $this->inputs;
111
+        if($this->inputs) {
112
+                    return $this->inputs;
113
+        }
112 114
 
113 115
         return $this->generateInputs($entity);
114 116
     }
Please login to merge, or discard this patch.
src/GeneratorServiceProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@
 block discarded – undo
26 26
         }
27 27
 
28 28
         $this->publishes([
29
-            __DIR__.'/config' => realpath('config'),
30
-            __DIR__.'/lang' => \Config::get('repository.lang_path')."/en",
31
-        ],'repository-generator');
29
+            __DIR__ . '/config' => realpath('config'),
30
+            __DIR__ . '/lang' => \Config::get('repository.lang_path') . "/en",
31
+        ], 'repository-generator');
32 32
 
33 33
         if ($this->app['config']->get('repository') === null) {
34
-            $this->app['config']->set('repository', require __DIR__.'/config/repository.php');
34
+            $this->app['config']->set('repository', require __DIR__ . '/config/repository.php');
35 35
         }
36
-        $this->mergeConfigFrom(__DIR__.'/config/repository.php', 'repository-config');
36
+        $this->mergeConfigFrom(__DIR__ . '/config/repository.php', 'repository-config');
37 37
         $this->publishes([
38
-            realpath(__DIR__ . '/../stubs') => \Config::get('repository.resources_path',realpath(__DIR__.'/../../../../resources/')),
39
-        ],'repository-stub');
38
+            realpath(__DIR__ . '/../stubs') => \Config::get('repository.resources_path', realpath(__DIR__ . '/../../../../resources/')),
39
+        ], 'repository-stub');
40 40
     }
41 41
 
42 42
     /**
Please login to merge, or discard this patch.