| Conditions | 5 |
| Paths | 6 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | protected function resolveCriteria(Resources $field, $criteria = null): ResourceCriteriaInterface |
||
| 34 | { |
||
| 35 | if ($criteria instanceof ResourceCriteriaInterface) { |
||
| 36 | return $criteria; |
||
| 37 | } |
||
| 38 | |||
| 39 | if ($criteria === null) { |
||
| 40 | return $field->createResourceCriteria(); |
||
| 41 | } |
||
| 42 | |||
| 43 | if (!is_array($criteria)) { |
||
| 44 | $criteria = ['class' => $criteria]; |
||
| 45 | } |
||
| 46 | |||
| 47 | try { |
||
| 48 | $criteria = ObjectHelper::create($criteria, ResourceCriteriaInterface::class); |
||
| 49 | } catch (InvalidConfigException $e) { |
||
| 50 | $criteria = $this->getCriteria($criteria); |
||
|
|
|||
| 51 | } |
||
| 52 | |||
| 53 | /** @var ResourceCriteriaInterface $criteria */ |
||
| 54 | |||
| 55 | return $criteria; |
||
| 56 | } |
||
| 57 | } |
||
| 58 |
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: