Completed
Pull Request — master (#212)
by Chris
03:26
created

DirectiveConfig::build()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 0
crap 3
1
<?php
2
/**
3
 * Date: 03/17/2017
4
 *
5
 * @author Volodymyr Rashchepkin <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Config\Directive;
9
10
11
use Youshido\GraphQL\Config\AbstractConfig;
12
use Youshido\GraphQL\Config\Traits\ArgumentsAwareConfigTrait;
13
use Youshido\GraphQL\Type\TypeService;
14
15
/**
16
 * Class DirectiveConfig
17
 *
18
 * @package Youshido\GraphQL\Config\Directive
19
 */
20
class DirectiveConfig extends AbstractConfig
21
{
22
23
    use ArgumentsAwareConfigTrait;
24
25
    protected $locations = [];
26
27
    public function getRules()
28
    {
29
        return [
30
            'name'        => ['type' => TypeService::TYPE_STRING, 'final' => true],
31
            'description' => ['type' => TypeService::TYPE_STRING],
32
            'args'        => ['type' => TypeService::TYPE_ARRAY],
33
            'locations'   => ['type' => TypeService::TYPE_ARRAY],
34
        ];
35
    }
36
37 1
    public function getLocations()
38
    {
39 1
        return $this->locations;
40
    }
41
42 3
    public function build()
43
    {
44 3
        $this->buildArguments();
45
46 3
        if (!empty($this->data['locations'])) {
47 1
            foreach ($this->data['locations'] as $location) {
48 1
                $this->locations[] = $location;
49
            }
50
        }
51 3
    }
52
53
}
54