Passed
Push — master ( fa923b...ffa870 )
by Christoffer
02:28
created

Directive::setLocations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Digia\GraphQL\Type\Definition;
4
5
use Digia\GraphQL\Error\InvariantException;
6
use Digia\GraphQL\Language\Node\ASTNodeAwareInterface;
7
use Digia\GraphQL\Language\Node\ASTNodeTrait;
8
use Digia\GraphQL\Language\Node\DirectiveDefinitionNode;
9
10
class Directive implements ASTNodeAwareInterface, ArgumentsAwareInterface
11
{
12
    use NameTrait;
13
    use DescriptionTrait;
14
    use ArgumentsTrait;
15
    use ASTNodeTrait;
16
17
    /**
18
     * @var string[]
19
     */
20
    protected $locations;
21
22
    /**
23
     * Directive constructor.
24
     *
25
     * @param string                       $name
26
     * @param null|string                  $description
27
     * @param string[]                     $locations
28
     * @param array                        $arguments
29
     * @param DirectiveDefinitionNode|null $astNode
30
     * @throws InvariantException
31
     */
32
    public function __construct(
33
        string $name,
34
        ?string $description,
35
        array $locations,
36
        array $arguments,
37
        ?DirectiveDefinitionNode $astNode
38
    ) {
39
        $this->name        = $name;
40
        $this->description = $description;
41
        $this->locations   = $locations;
42
        $this->astNode     = $astNode;
43
44
        $this->buildArguments($arguments);
45
    }
46
47
    /**
48
     * @return string[]
49
     */
50
    public function getLocations(): array
51
    {
52
        return $this->locations;
53
    }
54
}
55