Conditions | 6 |
Paths | 5 |
Total Lines | 16 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6.0359 |
Changes | 0 |
1 | <?php |
||
17 | 59 | public function resolve($value, array $args, ResolveInfo $info) |
|
18 | { |
||
19 | 59 | if ($resolveFunction = $this->getConfig()->getResolveFunction()) { |
|
|
|||
20 | 58 | return $resolveFunction($value, $args, $info); |
|
21 | } else { |
||
22 | 32 | if (is_array($value) && array_key_exists($this->getName(), $value)) { |
|
23 | 26 | return $value[$this->getName()]; |
|
24 | 12 | } elseif (is_object($value)) { |
|
25 | 9 | return TypeService::getPropertyValue($value, $this->getName()); |
|
26 | 3 | } elseif ($this->getType()->getNamedType()->getKind() == TypeMap::KIND_SCALAR) { |
|
27 | 3 | return null; |
|
28 | } else { |
||
29 | throw new \Exception(sprintf('Property "%s" not found in resolve result', $this->getName())); |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
40 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.