| Conditions | 7 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 12 | public function index(ModelAbstractorFactory $modelFactory) |
||
| 13 | { |
||
| 14 | $models = config('anavel-crud.models'); |
||
| 15 | |||
| 16 | if (empty($models)) { |
||
| 17 | throw new \Exception("No models configured."); |
||
| 18 | } |
||
| 19 | |||
| 20 | |||
| 21 | foreach ($models as $modelName => $model) { |
||
| 22 | $modelSlug = Slugger::slugify($modelName); |
||
| 23 | $modelAbstractor = $modelFactory->getByName($modelSlug); |
||
| 24 | $config = $modelAbstractor->getConfig(); |
||
| 25 | |||
| 26 | if (! array_key_exists('authorize', $config) || ($config['authorize'] === true && Gate::allows('adminIndex', $modelAbstractor->getInstance()) || $config['authorize'] === false)) { |
||
| 27 | return new RedirectResponse(route('anavel-crud.model.index', $modelSlug)); |
||
|
|
|||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | abort(403); |
||
| 32 | } |
||
| 33 | } |
||
| 34 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: