Passed
Pull Request — master (#233)
by Christoffer
03:30
created

OperationTypeDefinitionNode::getOperation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Digia\GraphQL\Language\Node;
4
5
use Digia\GraphQL\Language\Location;
6
7
class OperationTypeDefinitionNode extends AbstractNode implements DefinitionNodeInterface
8
{
9
    use TypeTrait;
10
11
    /**
12
     * @var string
13
     */
14
    protected $operation;
15
16
    /**
17
     * OperationTypeDefinitionNode constructor.
18
     *
19
     * @param string            $operation
20
     * @param TypeNodeInterface $type
21
     * @param Location|null     $location
22
     */
23
    public function __construct(string $operation, TypeNodeInterface $type, ?Location $location)
24
    {
25
        parent::__construct(NodeKindEnum::OPERATION_TYPE_DEFINITION, $location);
26
27
        $this->operation = $operation;
28
        $this->type      = $type;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getOperation(): string
35
    {
36
        return $this->operation;
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function toAST(): array
43
    {
44
        return [
45
            'kind'      => $this->kind,
46
            'operation' => $this->operation,
47
            'type'      => $this->getTypeAST(),
48
            'loc'       => $this->getLocationAST(),
49
        ];
50
    }
51
}
52