Passed
Branch master (a46fef)
by Adrian
09:07
created
src/Abstractor/Eloquent/Field.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     /**
126
-     * @return mixed
126
+     * @return string
127 127
      */
128 128
     public function getValue()
129 129
     {
@@ -162,6 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
     /**
164 164
      *
165
+     * @param boolean $value
165 166
      */
166 167
     public function hideValue($value = null)
167 168
     {
@@ -174,6 +175,7 @@  discard block
 block discarded – undo
174 175
 
175 176
     /**
176 177
      *
178
+     * @param boolean $value
177 179
      */
178 180
     public function saveIfEmpty($value = null)
179 181
     {
@@ -186,6 +188,7 @@  discard block
 block discarded – undo
186 188
 
187 189
     /**
188 190
      *
191
+     * @param boolean $value
189 192
      */
190 193
     public function noValidate($value = null)
191 194
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function presentation()
57 57
     {
58
-        return transcrud($this->presentation) ? : ucfirst(str_replace('_', ' ', transcrud($this->name)));
58
+        return transcrud($this->presentation) ?: ucfirst(str_replace('_', ' ', transcrud($this->name)));
59 59
     }
60 60
 
61 61
     public function type()
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
     public function setFunctions($functions)
91 91
     {
92
-        if (! is_array($functions)) {
92
+        if (!is_array($functions)) {
93 93
             $functions = array($functions);
94 94
         }
95 95
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     public function applyFunctions($value)
100 100
     {
101 101
         foreach ($this->functions as $function) {
102
-            if (! function_exists($function)) {
102
+            if (!function_exists($function)) {
103 103
                 throw new \Exception("Function ".$function." does not exist");
104 104
             }
105 105
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $this->value = $value;
119 119
 
120
-        if (! $this->hideValue()) {
120
+        if (!$this->hideValue()) {
121 121
             $this->formField->val($this->value);
122 122
         }
123 123
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
     public function getFormField()
153 153
     {
154
-        if (! $this->hideValue()) {
154
+        if (!$this->hideValue()) {
155 155
             if (Request::old($this->name)) {
156 156
                 $this->formField->val(Request::old($this->name));
157 157
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function hideValue($value = null)
167 167
     {
168
-        if (! is_null($value)) {
168
+        if (!is_null($value)) {
169 169
             $this->hideValue = $value;
170 170
         }
171 171
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function saveIfEmpty($value = null)
179 179
     {
180
-        if (! is_null($value)) {
180
+        if (!is_null($value)) {
181 181
             $this->saveIfEmpty = $value;
182 182
         }
183 183
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function noValidate($value = null)
191 191
     {
192
-        if (! is_null($value)) {
192
+        if (!is_null($value)) {
193 193
             $this->noValidate = $value;
194 194
         }
195 195
 
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Model.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -76,6 +76,9 @@  discard block
 block discarded – undo
76 76
         return transcrud($this->name);
77 77
     }
78 78
 
79
+    /**
80
+     * @return string
81
+     */
79 82
     public function getModel()
80 83
     {
81 84
         return $this->model;
@@ -91,6 +94,9 @@  discard block
 block discarded – undo
91 94
         return $this->getConfigValue('soft_deletes') ? true : false;
92 95
     }
93 96
 
97
+    /**
98
+     * @param string $action
99
+     */
94 100
     protected function getColumns($action, $withForeignKeys = false)
95 101
     {
96 102
         $tableColumns = $this->dbal->getTableColumns();
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
         }
115 115
 
116 116
         $customDisplayedColumns = $this->getConfigValue($action, 'display');
117
-        $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : [];
117
+        $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: [];
118 118
 
119 119
         $columns = array();
120
-        if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
120
+        if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
121 121
             foreach ($customDisplayedColumns as $customColumn) {
122
-                if (! array_key_exists($customColumn, $tableColumns)) {
122
+                if (!array_key_exists($customColumn, $tableColumns)) {
123 123
                     throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel());
124 124
                 }
125 125
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 
145 145
     public function getRelations()
146 146
     {
147
-        $configRelations =  $this->getConfigValue('relations');
147
+        $configRelations = $this->getConfigValue('relations');
148 148
 
149 149
         $relations = [];
150 150
 
151
-        if (! empty($configRelations)) {
151
+        if (!empty($configRelations)) {
152 152
             foreach ($configRelations as $relationName => $configRelation) {
153 153
                 if (is_int($relationName)) {
154 154
                     $relationName = $configRelation;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
                 $config = [];
158 158
                 if ($configRelation !== $relationName) {
159
-                    if (! is_array($configRelation)) {
159
+                    if (!is_array($configRelation)) {
160 160
                         $config['type'] = $configRelation;
161 161
                     } else {
162 162
                         $config = $configRelation;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $columns = $this->getColumns('list');
178 178
 
179
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
179
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
180 180
 
181 181
         $fields = array();
182 182
         foreach ($columns as $name => $column) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     {
207 207
         $columns = $this->getColumns('detail');
208 208
 
209
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
209
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
210 210
 
211 211
         $fields = array();
212 212
         foreach ($columns as $name => $column) {
@@ -236,15 +236,15 @@  discard block
 block discarded – undo
236 236
     {
237 237
         $columns = $this->getColumns('edit', $withForeignKeys);
238 238
 
239
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
240
-        $formTypes = $this->getConfigValue('edit', 'form_types') ? : [];
241
-        $validationRules = $this->getConfigValue('edit', 'validation') ? : [];
242
-        $functions = $this->getConfigValue('edit', 'functions') ? : [];
243
-        $defaults = $this->getConfigValue('edit', 'defaults') ? : [];
239
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
240
+        $formTypes = $this->getConfigValue('edit', 'form_types') ?: [];
241
+        $validationRules = $this->getConfigValue('edit', 'validation') ?: [];
242
+        $functions = $this->getConfigValue('edit', 'functions') ?: [];
243
+        $defaults = $this->getConfigValue('edit', 'defaults') ?: [];
244 244
 
245 245
         $fields = array();
246 246
         foreach ($columns as $name => $column) {
247
-            if (! in_array($name, $this->getReadOnlyColumns())) {
247
+            if (!in_array($name, $this->getReadOnlyColumns())) {
248 248
                 $presentation = null;
249 249
                 if (array_key_exists($name, $fieldsPresentation)) {
250 250
                     $presentation = $fieldsPresentation[$name];
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                     ->setConfig($config)
280 280
                     ->get();
281 281
 
282
-                if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) {
282
+                if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) {
283 283
                     $field->setValue($this->instance->getAttribute($name));
284 284
                 }
285 285
 
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
     {
320 320
         /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */
321 321
         $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager');
322
-        if (! empty($this->instance)) {
322
+        if (!empty($this->instance)) {
323 323
             $item = $this->instance;
324 324
         } else {
325 325
             $item = $modelManager->getModelInstance($this->getModel());
326 326
         }
327 327
 
328 328
         foreach ($this->getEditFields(true) as $field) {
329
-            if (! $field->saveIfEmpty() && empty($request->input($field->getName()))) {
329
+            if (!$field->saveIfEmpty() && empty($request->input($field->getName()))) {
330 330
                 continue;
331 331
             }
332 332
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                 }
347 347
             }
348 348
 
349
-            if (! empty($requestValue)) {
349
+            if (!empty($requestValue)) {
350 350
                 $item->setAttribute(
351 351
                     $field->getName(),
352 352
                     $field->applyFunctions($requestValue)
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 
359 359
         $this->setInstance($item);
360 360
 
361
-        if (! empty($relations = $this->getRelations())) {
361
+        if (!empty($relations = $this->getRelations())) {
362 362
             foreach ($relations as $relation) {
363 363
                 $relation->persist($request);
364 364
             }
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/ModelFactory.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-     * @param $slug
41
+     * @param string $slug
42 42
      * @param null $id
43
-     * @return Model|null
43
+     * @return Model
44 44
      * @throws \Exception
45 45
      */
46 46
     public function getBySlug($slug, $id = null)
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/MiniCrud.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility;
5 5
 use Anavel\Crud\Contracts\Abstractor\Field;
6
-use App;
7 6
 use Illuminate\Database\Eloquent\Model;
8 7
 use Illuminate\Http\Request;
9 8
 use Illuminate\Support\Collection;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $results = $this->eloquentRelation->getResults();
38 38
 
39 39
         $results->put('emptyResult', '');
40
-        if (! empty($columns)) {
40
+        if (!empty($columns)) {
41 41
             $readOnly = [Model::CREATED_AT, Model::UPDATED_AT];
42 42
             foreach ($results as $key => $result) {
43 43
                 foreach ($columns as $columnName => $column) {
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
                     }
57 57
 
58 58
                     $config = [
59
-                        'name'         => $this->name . '[' . $index . '][' . $columnName . ']',
60
-                        'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)) . ' [' . $index . ']',
59
+                        'name'         => $this->name.'['.$index.']['.$columnName.']',
60
+                        'presentation' => $this->name.' '.ucfirst(transcrud($columnName)).' ['.$index.']',
61 61
                         'form_type'    => $formType,
62 62
                         'no_validate'  => true,
63 63
                         'validation'   => null,
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function persist(Request $request)
93 93
     {
94
-        if (! empty($relationArray = $request->input($this->name))) {
94
+        if (!empty($relationArray = $request->input($this->name))) {
95 95
             $currentRelations = $this->eloquentRelation->get()->keyBy($this->eloquentRelation->getParent()->getKeyName());
96 96
             foreach ($relationArray as $relation) {
97
-                if (! empty($relation[$this->eloquentRelation->getParent()->getKeyName()])
97
+                if (!empty($relation[$this->eloquentRelation->getParent()->getKeyName()])
98 98
                     && ($currentRelations->has($relation[$this->eloquentRelation->getParent()->getKeyName()]))
99 99
                 ) {
100 100
                     $relationModel = $currentRelations->get($relation[$this->eloquentRelation->getParent()->getKeyName()]);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     $relationModel->setAttribute($fieldKey, $fieldValue);
113 113
                 }
114 114
 
115
-                if (! $shouldBeSkipped) {
115
+                if (!$shouldBeSkipped) {
116 116
                     $relationModel->save();
117 117
                 }
118 118
             }
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/MiniCrudSingle.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,10 +3,8 @@
 block discarded – undo
3 3
 
4 4
 use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility;
5 5
 use Anavel\Crud\Contracts\Abstractor\Field;
6
-use App;
7 6
 use Illuminate\Database\Eloquent\Model;
8 7
 use Illuminate\Http\Request;
9
-use Illuminate\Support\Collection;
10 8
 
11 9
 class MiniCrudSingle extends Relation
12 10
 {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         ];
46 46
 
47 47
 
48
-        if (! empty($columns)) {
48
+        if (!empty($columns)) {
49 49
             foreach ($columns as $columnName => $column) {
50 50
                 if (in_array($columnName, $readOnly, true)) {
51 51
                     continue;
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
                 $formType = null;
55 55
 
56 56
                 $config = [
57
-                    'name'         => $this->name . '[' . $columnName . ']',
58
-                    'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)),
57
+                    'name'         => $this->name.'['.$columnName.']',
58
+                    'presentation' => $this->name.' '.ucfirst(transcrud($columnName)),
59 59
                     'form_type'    => $formType,
60 60
                     'no_validate'  => true,
61 61
                     'validation'   => null,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     ->setConfig($config)
69 69
                     ->get();
70 70
 
71
-                if (! empty($result->id)) {
71
+                if (!empty($result->id)) {
72 72
                     $field->setValue($result->getAttribute($columnName));
73 73
                 }
74 74
 
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function persist(Request $request)
90 90
     {
91
-        if (! empty($relation = $request->input($this->name))) {
91
+        if (!empty($relation = $request->input($this->name))) {
92 92
             $currentRelation = $this->eloquentRelation->getResults();
93
-            if (! empty($currentRelation)) {
93
+            if (!empty($currentRelation)) {
94 94
                 $relationModel = $currentRelation;
95 95
             } else {
96 96
                 $relationModel = $this->eloquentRelation->getRelated()->newInstance();
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 $relationModel->setAttribute($fieldKey, $fieldValue);
107 107
             }
108 108
 
109
-            if (! $shouldBeSkipped) {
109
+            if (!$shouldBeSkipped) {
110 110
                 $relationModel->save();
111 111
             }
112 112
         }
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/SelectMultiple.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,7 @@
 block discarded – undo
2 2
 namespace Anavel\Crud\Abstractor\Eloquent\Relation;
3 3
 
4 4
 use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility;
5
-use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationConfig;
6 5
 use Anavel\Crud\Repository\Criteria\InArrayCriteria;
7
-use App;
8 6
 use Doctrine\DBAL\Schema\Column;
9 7
 use Illuminate\Http\Request;
10 8
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function persist(Request $request)
30 30
     {
31
-        if (! empty($selectArray = $request->input($this->name))) {
31
+        if (!empty($selectArray = $request->input($this->name))) {
32 32
             /** @var \ANavallaSuiza\Laravel\Database\Contracts\Repository\Repository $repo */
33 33
             $repo = $this->modelManager->getRepository(get_class($this->eloquentRelation->getRelated()));
34 34
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                 $result->save();
50 50
             }
51 51
 
52
-            if (! $missing->isEmpty()) {
52
+            if (!$missing->isEmpty()) {
53 53
                 foreach ($missing as $result) {
54 54
                     $result->$keyName = null;
55 55
                     $result->save();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $results = $this->eloquentRelation->getResults();
84 84
 
85
-        if (! $results->isEmpty()) {
85
+        if (!$results->isEmpty()) {
86 86
             $values = [];
87 87
 
88 88
             foreach ($results as $result) {
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/Translation.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility;
5 5
 use Anavel\Crud\Contracts\Abstractor\Field;
6
-use App;
7 6
 use Illuminate\Http\Request;
8 7
 
9 8
 class Translation extends Relation
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $results = $results->keyBy('locale');
40 40
 
41 41
         $translationFields = [];
42
-        if (! empty($columns)) {
42
+        if (!empty($columns)) {
43 43
             foreach ($this->langs as $key => $lang) {
44 44
                 foreach ($columns as $columnName => $column) {
45 45
                     if ($columnName === $this->eloquentRelation->getPlainForeignKey()) {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
                     $config = [
60 60
                         'name' => $this->name.'['.$key.']['.$columnName.']',
61
-                        'presentation' => ucfirst(transcrud($columnName)).' ['.$lang .']',
61
+                        'presentation' => ucfirst(transcrud($columnName)).' ['.$lang.']',
62 62
                         'form_type' => $formType,
63 63
                         'no_validate' => true,
64 64
                         'validation' => null,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function persist(Request $request)
96 96
     {
97
-        if (! empty($translationsArray = $request->input($this->name))) {
97
+        if (!empty($translationsArray = $request->input($this->name))) {
98 98
             $currentTranslations = $this->eloquentRelation->get();
99 99
             $currentTranslations = $currentTranslations->keyBy('locale');
100 100
 
Please login to merge, or discard this patch.
src/Http/Controllers/ModelController.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @param Request $request
82 82
      * @param  string  $model
83
-     * @return Response
83
+     * @return \Illuminate\Http\RedirectResponse
84 84
      */
85 85
     public function store(Request $request, $model)
86 86
     {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      * @param Request $request
149 149
      * @param  string  $model
150 150
      * @param  int  $id
151
-     * @return Response
151
+     * @return \Illuminate\Http\RedirectResponse
152 152
      */
153 153
     public function update(Request $request, $model, $id)
154 154
     {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      * @param Request $request
178 178
      * @param  string  $model
179 179
      * @param  int  $id
180
-     * @return Response
180
+     * @return \Illuminate\Http\RedirectResponse
181 181
      */
182 182
     public function destroy(Request $request, $model, $id)
183 183
     {
Please login to merge, or discard this patch.
src/Abstractor/ConfigurationReader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 {
6 6
     public function getConfigValue()
7 7
     {
8
-        if (! property_exists($this, 'config') || ! is_array($this->config) || empty($this->config)) {
8
+        if (!property_exists($this, 'config') || !is_array($this->config) || empty($this->config)) {
9 9
             return null;
10 10
         }
11 11
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
         if (is_array($params) && count($params) > 0) {
19 19
             foreach ($params as $configKey) {
20
-                if (! array_key_exists($configKey, $nestedConfig)) {
20
+                if (!array_key_exists($configKey, $nestedConfig)) {
21 21
                     $nestedConfig = array();
22 22
                     return null;
23 23
                 }
Please login to merge, or discard this patch.