Passed
Push — master ( b5049f...66570f )
by Mohammad
03:21
created
src/Forms/FormGenerator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function generateForm($entity, $method = 'post')
74 74
     {
75 75
         $html = '<form method="post" action="#">
76
-           <input type="hidden" name="__method" value="'.$method.'">';
76
+           <input type="hidden" name="__method" value="'.$method . '">';
77 77
         $html .= $this->getInputs($entity);
78 78
         $html .= '</form>';
79 79
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function getFillables($entity)
89 89
     {
90
-        if (! empty($entity->getFillable())) {
90
+        if (!empty($entity->getFillable())) {
91 91
             return $entity->getFillable();
92 92
         }
93 93
 
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
@@ -72,6 +72,6 @@
 block discarded – undo
72 72
 
73 73
     public function getFormStub($type)
74 74
     {
75
-        return file_get_contents(Config::get('repository.stubs_path').'/fields-'.$type.'.stub');
75
+        return file_get_contents(Config::get('repository.stubs_path') . '/fields-' . $type . '.stub');
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
src/RepositoryServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@
 block discarded – undo
40 40
         parent::__construct($app);
41 41
 
42 42
         if (null === $this->app['config']->get('repository')) {
43
-            $this->app['config']->set('repository', require __DIR__.'/config/repository.php');
43
+            $this->app['config']->set('repository', require __DIR__ . '/config/repository.php');
44 44
         }
45 45
         $interfaces = Str::plural(Config::get('repository.interface'));
46 46
         $repositories = Str::plural(Config::get('repository.repository'));
47 47
         $interface = Config::get('repository.interface');
48 48
         $repository = Config::get('repository.repository');
49 49
 
50
-        $contractsFolder = Config::get('repository.app_path').'/'.$interfaces;
50
+        $contractsFolder = Config::get('repository.app_path') . '/' . $interfaces;
51 51
 
52 52
         if (is_dir($contractsFolder)) {
53 53
             $directory = new RecursiveDirectoryIterator($contractsFolder);
Please login to merge, or discard this patch.
src/GeneratorServiceProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,25 +23,25 @@
 block discarded – undo
23 23
         }
24 24
 
25 25
         $this->publishes([
26
-            __DIR__.'/config' => realpath('config'),
26
+            __DIR__ . '/config' => realpath('config'),
27 27
         ], 'repository-generator');
28 28
 
29 29
         if (null === $this->app['config']->get('repository')) {
30
-            $this->app['config']->set('repository', require __DIR__.'/config/repository.php');
30
+            $this->app['config']->set('repository', require __DIR__ . '/config/repository.php');
31 31
         }
32
-        $this->mergeConfigFrom(__DIR__.'/config/repository.php', 'repository-config');
33
-        $resourcesPathStub = realpath(__DIR__.'/../../../../resources') .'/stubs';
34
-        $stubPath = realpath(__DIR__.'/../stubs');
35
-        $langPath = Config::get('repository.lang_path').'/en';
32
+        $this->mergeConfigFrom(__DIR__ . '/config/repository.php', 'repository-config');
33
+        $resourcesPathStub = realpath(__DIR__ . '/../../../../resources') . '/stubs';
34
+        $stubPath = realpath(__DIR__ . '/../stubs');
35
+        $langPath = Config::get('repository.lang_path') . '/en';
36 36
 
37
-        if(!is_dir($resourcesPathStub))
37
+        if (!is_dir($resourcesPathStub))
38 38
         {
39
-            mkdir($resourcesPathStub,0777,true);
39
+            mkdir($resourcesPathStub, 0777, true);
40 40
         }
41 41
 
42 42
         $this->publishes([
43 43
             $stubPath => Config::get('repository.stubs_path', $resourcesPathStub),
44
-            __DIR__.'/lang' => $langPath,
44
+            __DIR__ . '/lang' => $langPath,
45 45
         ], 'repository-stub');
46 46
     }
47 47
 
Please login to merge, or discard this patch.
src/Utility/Controller.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $this->breadcrumbs = new Collection();
66 66
 
67 67
         $language = $request->header('Language', 'en');
68
-        if (! in_array($language, Config::get('app.locales', []))) {
68
+        if (!in_array($language, Config::get('app.locales', []))) {
69 69
             $language = 'en';
70 70
         }
71 71
         $limit = $request->get('limit', 10);
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
         $this->interface = $interface;
112 112
         $this->isAPI = $request->expectsJson();
113 113
 
114
-        if (! $this->isAPI) {
114
+        if (!$this->isAPI) {
115 115
             $this->breadcrumbs = new Collection();
116 116
             $this->search = new Collection();
117
-            View::share('pageTitle', $this->pageTitle.' | '.Config::get('app.name'));
117
+            View::share('pageTitle', $this->pageTitle . ' | ' . Config::get('app.name'));
118 118
             View::share('breadcrumbs', $this->breadcrumbs);
119 119
             View::share('menu', $this->menu);
120 120
             View::share('search', $this->search);
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
     {
134 134
         $data = $this->interface->simplePaginate($this->limit, $this->request->all());
135 135
 
136
-        if (! $this->isAPI) {
137
-            View::share('pageTitle', 'List '.$this->pageTitle.' | '.Config::get('app.name'));
136
+        if (!$this->isAPI) {
137
+            View::share('pageTitle', 'List ' . $this->pageTitle . ' | ' . Config::get('app.name'));
138 138
             $this->breadcrumbs->put('index', [
139 139
                 'link' => $this->routeIndex,
140 140
                 'text' => $this->pageTitle,
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function create()
165 165
     {
166
-        if (! $this->isAPI) {
167
-            View::share('pageTitle', 'Create '.$this->pageTitle.' | '.Config::get('app.name'));
166
+        if (!$this->isAPI) {
167
+            View::share('pageTitle', 'Create ' . $this->pageTitle . ' | ' . Config::get('app.name'));
168 168
             $this->breadcrumbs->put('create', [
169 169
                 'link' => $this->createRoute,
170 170
                 'text' => trans('repository-generator.create'),
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
     public function show($entityId)
199 199
     {
200 200
         $entity = $this->interface->find($entityId);
201
-        if (! $this->isAPI) {
202
-            if (! $entity) {
201
+        if (!$this->isAPI) {
202
+            if (!$entity) {
203 203
                 return Redirect::to($this->routeIndex)->with('warning', __('repository-generator.not_found'));
204 204
             }
205
-            View::share('pageTitle', 'View '.$this->pageTitle.' | '.Config::get('app.name'));
205
+            View::share('pageTitle', 'View ' . $this->pageTitle . ' | ' . Config::get('app.name'));
206 206
             $this->breadcrumbs->put('view', [
207 207
                 'link' => '',
208 208
                 'text' => __('repository-generator.show'),
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             return view($this->viewShow, $this->params)
212 212
                 ->with('entity', $entity);
213 213
         }
214
-        if (! $entity) {
214
+        if (!$entity) {
215 215
             return response()->json(null, JsonResponse::HTTP_NOT_FOUND);
216 216
         }
217 217
 
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
     public function edit($entityId)
232 232
     {
233 233
         $entity = $this->interface->find($entityId);
234
-        if (! $this->isAPI) {
235
-            if (! $entity) {
234
+        if (!$this->isAPI) {
235
+            if (!$entity) {
236 236
                 return Redirect::to($this->routeIndex)->with('warning', __('repository-generator.not_found'));
237 237
             }
238 238
             $this->breadcrumbs->put('edit', [
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function makeResponse($entity, $appendEntity = false)
317 317
     {
318
-        if (! $this->isAPI) {
318
+        if (!$this->isAPI) {
319 319
             if ($entity) {
320 320
                 return Redirect::to($this->routeIndex)->with('message', __('repository-generator.success'));
321 321
             }
Please login to merge, or discard this patch.
src/Commands/Generator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function handle()
63 63
     {
64
-        $file = preg_split(' (/|\\\\) ', (string)$this->argument('name')) ?? [];
64
+        $file = preg_split(' (/|\\\\) ', (string) $this->argument('name')) ?? [];
65 65
 
66
-        if (! $file) {
66
+        if (!$file) {
67 67
             return 'Something wrong with the inputs !';
68 68
         }
69 69
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
                 $content = $filePath . $repoName . '.php';
280 280
         }
281 281
 
282
-        if(is_dir($filePath) && file_exists($content)){
282
+        if (is_dir($filePath) && file_exists($content)) {
283 283
             // Ask to replace exiting file
284
-            if (! $this->confirm("This file, {$content} already exit, do you want to replace?")) {
284
+            if (!$this->confirm("This file, {$content} already exit, do you want to replace?")) {
285 285
                 $this->line('File Not Replaced');
286 286
                 return false;
287 287
             }
Please login to merge, or discard this patch.
src/config/repository.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
  * Time: 09:58 am.
7 7
  */
8 8
 return [
9
-    'app_path' => realpath(__DIR__.'/../app/'),
9
+    'app_path' => realpath(__DIR__ . '/../app/'),
10 10
     'route_path' => realpath('routes/'),
11 11
     'resources_path' => realpath('resources'),
12
-    'stubs_path' => realpath('resources').'/stubs/',
13
-    'lang_path' => realpath('resources').'/lang/',
12
+    'stubs_path' => realpath('resources') . '/stubs/',
13
+    'lang_path' => realpath('resources') . '/lang/',
14 14
     'config_path' => realpath('config'),
15 15
 
16 16
     //relative to app path
Please login to merge, or discard this patch.
src/Commands/Remover.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $file = preg_split(' (/|\\\\) ', (string) $this->argument('name')) ?? [];
55 55
 
56
-        if (! $file) {
56
+        if (!$file) {
57 57
             return 'Something wrong with the inputs !';
58 58
         }
59 59
 
@@ -62,32 +62,32 @@  discard block
 block discarded – undo
62 62
         unset($file[count($file) - 1]);
63 63
         $path = implode('\\', $file);
64 64
 
65
-        if (!$this->confirm('This will delete '.$this->repoName.' files and folder, Do you want to continue ?')) {
65
+        if (!$this->confirm('This will delete ' . $this->repoName . ' files and folder, Do you want to continue ?')) {
66 66
             return false;
67 67
         }
68 68
 
69 69
         $model = Str::plural(Config::get('repository.model'));
70 70
         $interface = Str::plural(Config::get('repository.interface'));
71 71
         $repository = Str::plural(Config::get('repository.repository'));
72
-        $controllerFolder =  Config::get('repository.controllers_folder');
72
+        $controllerFolder = Config::get('repository.controllers_folder');
73 73
         $requestFolder = Config::get('repository.requests_folder');
74 74
 
75
-        $this->remove('Entity',$model,$path);
76
-        $this->remove('Controller',$controllerFolder,$path);
77
-        $this->remove('Request',$requestFolder,$path);
78
-        $this->remove('Repository',$repository,$path);
79
-        $this->remove('Interface',$interface,$path);
75
+        $this->remove('Entity', $model, $path);
76
+        $this->remove('Controller', $controllerFolder, $path);
77
+        $this->remove('Request', $requestFolder, $path);
78
+        $this->remove('Repository', $repository, $path);
79
+        $this->remove('Interface', $interface, $path);
80 80
         return true;
81 81
     }
82 82
 
83
-    public function remove($type,$folder,$relativePath)
83
+    public function remove($type, $folder, $relativePath)
84 84
     {
85 85
         $folder = str_replace('\\', '/', $folder);
86 86
         $relativePath = str_replace('\\', '/', $relativePath);
87 87
 
88 88
         switch ($type) {
89 89
             case 'Entity':
90
-                $filePath = Config::get('repository.app_path')."/{$folder}/{$relativePath}/";
90
+                $filePath = Config::get('repository.app_path') . "/{$folder}/{$relativePath}/";
91 91
                 $fileName = "{$this->repoName}.php";
92 92
                 break;
93 93
             case 'Controller':
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
                 $filePath = Config::get('repository.app_path') . "/{$folder}/{$relativePath}/";
99 99
                 $fileName = "{$this->repoName}{$type}.php";
100 100
         }
101
-        if(!is_file($filePath.$fileName))
101
+        if (!is_file($filePath . $fileName))
102 102
         {
103
-            $this->warn($filePath.' is not a valid file');
103
+            $this->warn($filePath . ' is not a valid file');
104 104
             return false;
105 105
         }
106 106
 
107
-        unlink($filePath.$fileName);
108
-        if(!(new \FilesystemIterator($filePath))->valid())
107
+        unlink($filePath . $fileName);
108
+        if (!(new \FilesystemIterator($filePath))->valid())
109 109
         {
110 110
             rmdir($filePath);
111 111
         }
Please login to merge, or discard this patch.
src/Utility/AbstractRepository.php 2 patches
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -258,14 +258,16 @@  discard block
 block discarded – undo
258 258
     {
259 259
         if($this->allowCaching)
260 260
         {
261
-            if (isset($this->cache[$entityId]))
262
-                return $this->cache[$entityId];
261
+            if (isset($this->cache[$entityId])) {
262
+                            return $this->cache[$entityId];
263
+            }
263 264
         }
264 265
 
265 266
         $entity = $this->model->with($this->with)->find($entityId, $columns);
266 267
 
267
-        if($this->allowCaching)
268
-            $this->cache[$entityId] = $entity;
268
+        if($this->allowCaching) {
269
+                    $this->cache[$entityId] = $entity;
270
+        }
269 271
 
270 272
         return $entity;
271 273
     }
@@ -282,14 +284,16 @@  discard block
 block discarded – undo
282 284
     {
283 285
         if($this->allowCaching)
284 286
         {
285
-            if (isset($this->cache[$entityId]))
286
-                return $this->cache[$entityId];
287
+            if (isset($this->cache[$entityId])) {
288
+                            return $this->cache[$entityId];
289
+            }
287 290
         }
288 291
 
289 292
         $entity = $this->model->with($this->with)->findOrFail($entityId, $columns);
290 293
 
291
-        if($this->allowCaching)
292
-            $this->cache[$entityId] = $entity;
294
+        if($this->allowCaching) {
295
+                    $this->cache[$entityId] = $entity;
296
+        }
293 297
 
294 298
         return $entity;
295 299
     }
@@ -304,14 +308,16 @@  discard block
 block discarded – undo
304 308
     {
305 309
         if($this->allowCaching)
306 310
         {
307
-            if (isset($this->cache['first']))
308
-                return $this->cache['first'];
311
+            if (isset($this->cache['first'])) {
312
+                            return $this->cache['first'];
313
+            }
309 314
         }
310 315
 
311 316
         $entity = $this->model->with($this->with)->select($columns)->where($filter)->first();
312 317
 
313
-        if($this->allowCaching)
314
-            $this->cache['first'] = $entity;
318
+        if($this->allowCaching) {
319
+                    $this->cache['first'] = $entity;
320
+        }
315 321
 
316 322
         return $entity;
317 323
     }
@@ -326,15 +332,17 @@  discard block
 block discarded – undo
326 332
     {
327 333
         if($this->allowCaching)
328 334
         {
329
-            if (isset($this->cache['last']))
330
-                return $this->cache['last'];
335
+            if (isset($this->cache['last'])) {
336
+                            return $this->cache['last'];
337
+            }
331 338
         }
332 339
 
333 340
         $entity = $this->model->with($this->with)->select($columns)->where($filter)
334 341
             ->orderBy('id','desc')->first();
335 342
 
336
-        if($this->allowCaching)
337
-            $this->cache['last'] = $entity;
343
+        if($this->allowCaching) {
344
+                    $this->cache['last'] = $entity;
345
+        }
338 346
 
339 347
         return $entity;
340 348
     }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
         if (isset($criteria['search'])) {
116 116
             foreach ($this->model->searchable as $method => $columns) {
117 117
                 if (method_exists($this->model, $method)) {
118
-                    $latest->orWhereHas($method, function ($query) use ($criteria, $columns) {
118
+                    $latest->orWhereHas($method, function($query) use ($criteria, $columns) {
119 119
                         /* @var $query Builder */
120
-                        $query->where(function ($query2) use ($criteria, $columns) {
120
+                        $query->where(function($query2) use ($criteria, $columns) {
121 121
                             /* @var $query2 Builder */
122 122
                             foreach ((array) $columns as $column) {
123
-                                $query2->orWhere($column, 'like', '%'.$criteria['search'].'%');
123
+                                $query2->orWhere($column, 'like', '%' . $criteria['search'] . '%');
124 124
                             }
125 125
                         });
126 126
                     });
127 127
                 } else {
128
-                    $latest->orWhere($columns, 'like', '%'.$criteria['search'].'%');
128
+                    $latest->orWhere($columns, 'like', '%' . $criteria['search'] . '%');
129 129
                 }
130 130
             }
131 131
         }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param array $columns
182 182
      * @return Builder[]|Collection
183 183
      */
184
-    public function get($criteria = [],$columns = [])
184
+    public function get($criteria = [], $columns = [])
185 185
     {
186 186
         return $this->filter($criteria)->get($columns);
187 187
     }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function find($entityId = 0, $columns = ['*'])
249 249
     {
250
-        if($this->allowCaching)
250
+        if ($this->allowCaching)
251 251
         {
252 252
             if (isset($this->cache[$entityId]))
253 253
                 return $this->cache[$entityId];
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
         $entity = $this->model->with($this->with)->find($entityId, $columns);
257 257
 
258
-        if($this->allowCaching)
258
+        if ($this->allowCaching)
259 259
             $this->cache[$entityId] = $entity;
260 260
 
261 261
         return $entity;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      */
272 272
     public function findOrFail($entityId = 0, $columns = ['*'])
273 273
     {
274
-        if($this->allowCaching)
274
+        if ($this->allowCaching)
275 275
         {
276 276
             if (isset($this->cache[$entityId]))
277 277
                 return $this->cache[$entityId];
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
         $entity = $this->model->with($this->with)->findOrFail($entityId, $columns);
281 281
 
282
-        if($this->allowCaching)
282
+        if ($this->allowCaching)
283 283
             $this->cache[$entityId] = $entity;
284 284
 
285 285
         return $entity;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function first($filter = [], $columns = ['*'])
295 295
     {
296
-        if($this->allowCaching)
296
+        if ($this->allowCaching)
297 297
         {
298 298
             if (isset($this->cache['first']))
299 299
                 return $this->cache['first'];
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
         $entity = $this->model->with($this->with)->select($columns)->where($filter)->first();
303 303
 
304
-        if($this->allowCaching)
304
+        if ($this->allowCaching)
305 305
             $this->cache['first'] = $entity;
306 306
 
307 307
         return $entity;
@@ -315,16 +315,16 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function last($filter = [], $columns = ['*'])
317 317
     {
318
-        if($this->allowCaching)
318
+        if ($this->allowCaching)
319 319
         {
320 320
             if (isset($this->cache['last']))
321 321
                 return $this->cache['last'];
322 322
         }
323 323
 
324 324
         $entity = $this->model->with($this->with)->select($columns)->where($filter)
325
-            ->orderBy('id','desc')->first();
325
+            ->orderBy('id', 'desc')->first();
326 326
 
327
-        if($this->allowCaching)
327
+        if ($this->allowCaching)
328 328
             $this->cache['last'] = $entity;
329 329
 
330 330
         return $entity;
Please login to merge, or discard this patch.