Conditions | 8 |
Paths | 15 |
Total Lines | 25 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 8.0189 |
Changes | 0 |
1 | <?php |
||
16 | 25 | public function resolve($value, array $args, ResolveInfo $info) |
|
17 | { |
||
18 | 25 | if ($this->resolveFunctionCache === null) { |
|
19 | 25 | $this->resolveFunctionCache = $this->getConfig()->getResolveFunction(); |
|
20 | |||
21 | 25 | if (!$this->resolveFunctionCache) { |
|
22 | 20 | $this->resolveFunctionCache = false; |
|
23 | } |
||
24 | } |
||
25 | 25 | if ($this->resolveFunctionCache) { |
|
26 | 24 | $resolveFunction = $this->resolveFunctionCache; |
|
27 | |||
28 | 24 | return $resolveFunction($value, $args, $info); |
|
29 | } else { |
||
30 | 20 | if (is_array($value) && array_key_exists($this->getName(), $value)) { |
|
31 | 14 | return $value[$this->getName()]; |
|
32 | 9 | } elseif (is_object($value)) { |
|
33 | 6 | return TypeService::getPropertyValue($value, $this->getName()); |
|
34 | 3 | } elseif ($this->getType()->getNamedType()->getKind() == TypeMap::KIND_SCALAR) { |
|
35 | 3 | return null; |
|
36 | } else { |
||
37 | throw new \Exception(sprintf('Property "%s" not found in resolve result', $this->getName())); |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
47 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: