Passed
Pull Request — master (#23)
by Christoffer
02:07 queued 19s
created

TypeTrait::setType()   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 TypeTrait
8
{
9
10
    /**
11
     * @var TypeNodeInterface|SerializationInterface
12
     */
13
    protected $type;
14
15
    /**
16
     * @return TypeNodeInterface
17
     */
18
    public function getType(): TypeNodeInterface
19
    {
20
        return $this->type;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->type could return the type Digia\GraphQL\Util\SerializationInterface which is incompatible with the type-hinted return Digia\GraphQL\Language\AST\Node\TypeNodeInterface. Consider adding an additional type-check to rule them out.
Loading history...
21
    }
22
23
    /**
24
     * @return array
25
     */
26
    public function getTypeAsArray(): array
27
    {
28
        return $this->type->toArray();
0 ignored issues
show
Bug introduced by
The method toArray() does not exist on Digia\GraphQL\Language\AST\Node\TypeNodeInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Digia\GraphQL\Language\AST\Node\TypeNodeInterface. ( 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 $this->type->/** @scrutinizer ignore-call */ toArray();
Loading history...
29
    }
30
31
    /**
32
     * @param TypeNodeInterface $type
33
     * @return $this
34
     */
35
    public function setType(TypeNodeInterface $type)
36
    {
37
        $this->type = $type;
38
        return $this;
39
    }
40
}
41