Completed
Push — master ( bd3178...998f3f )
by Christoffer
04:52 queued 02:42
created

ValueLiteralTrait::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
use Digia\GraphQL\Util\SerializationInterface;
6
7
trait ValueLiteralTrait
8
{
9
10
    /**
11
     * @var ValueNodeInterface|SerializationInterface|null
12
     */
13
    protected $value;
14
15
    /**
16
     * @return ValueNodeInterface|null
17
     */
18
    public function getValue(): ?ValueNodeInterface
19
    {
20
        return $this->value;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->value could return the type Digia\GraphQL\Util\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 getValueAsArray(): array
27
    {
28
        return null !== $this->value ? $this->value->toArray() : null;
0 ignored issues
show
Bug Best Practice introduced by
The expression return null !== $this->v...value->toArray() : null could return the type null which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
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->value ? $this->value->/** @scrutinizer ignore-call */ toArray() : null;
Loading history...
29
    }
30
31
    /**
32
     * @param ValueNodeInterface|null $value
33
     * @return $this
34
     */
35
    public function setValue(?ValueNodeInterface $value)
36
    {
37
        $this->value = $value;
38
        return $this;
39
    }
40
}
41