Passed
Push — master ( 974e77...edaba1 )
by Christoffer
02:10
created

DefaultValueTrait::getDefaultValueAsArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
use Digia\GraphQL\SerializationInterface;
6
7
trait DefaultValueTrait
8
{
9
10
    /**
11
     * @var ValueNodeInterface|SerializationInterface|null
12
     */
13
    protected $defaultValue;
14
15
    /**
16
     * @return ValueNodeInterface|SerializationInterface|null
17
     */
18
    public function getDefaultValue(): ?ValueNodeInterface
19
    {
20
        return $this->defaultValue;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->defaultValue could return the type Digia\GraphQL\SerializationInterface which is incompatible with the type-hinted return null|Digia\GraphQL\Langu...Node\ValueNodeInterface. Consider adding an additional type-check to rule them out.
Loading history...
21
    }
22
23
    /**
24
     * @return array
25
     */
26
    public function getDefaultValueAsArray(): ?array
27
    {
28
        return null !== $this->defaultValue ? $this->defaultValue->toArray() : null;
0 ignored issues
show
Bug introduced by
The method toArray() does not exist on Digia\GraphQL\Language\AST\Node\ValueNodeInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Digia\GraphQL\Language\AST\Node\ValueNodeInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        return null !== $this->defaultValue ? $this->defaultValue->/** @scrutinizer ignore-call */ toArray() : null;
Loading history...
29
    }
30
}
31