DirectiveConfig   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 34
ccs 10
cts 16
cp 0.625
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRules() 0 9 1
A getLocations() 0 4 1
A build() 0 10 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 1
            }
50 1
        }
51 3
    }
52
53
}
54