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

NameTrait::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
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
trait NameTrait
6
{
7
8
    /**
9
     * @var NameNode|null
10
     */
11
    protected $name;
12
13
    /**
14
     * @return NameNode|null
15
     */
16
    public function getName(): ?NameNode
17
    {
18
        return $this->name;
19
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function getNameValue(): string
25
    {
26
        return $this->name->getValue();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->name->getValue() could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
Bug introduced by
The method getValue() does not exist on null. ( Ignorable by Annotation )

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

26
        return $this->name->/** @scrutinizer ignore-call */ getValue();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
    }
28
29
    /**
30
     * @return array|null
31
     */
32
    public function getNameAsArray(): ?array
33
    {
34
        return null !== $this->name ? $this->name->toArray() : null;
35
    }
36
}
37