Completed
Pull Request — master (#77)
by Sebastian
03:02
created

SchemaConfig::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 0
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/*
3
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/28/15 3:53 PM
7
*/
8
9
namespace Youshido\GraphQL\Config\Schema;
10
11
12
use Youshido\GraphQL\Config\AbstractConfig;
13
use Youshido\GraphQL\Type\Object\AbstractObjectType;
14
use Youshido\GraphQL\Type\Object\ObjectType;
15
use Youshido\GraphQL\Type\SchemaTypesList;
16
use Youshido\GraphQL\Type\TypeService;
17
18
class SchemaConfig extends AbstractConfig
19
{
20
21
    /**
22
     * @var SchemaTypesList
23
     */
24
    private $typesList;
25
26 49
    public function __construct(array $configData, $contextObject = null, $finalClass = false)
27
    {
28 49
        $this->typesList = new SchemaTypesList();
29 49
        parent::__construct($configData, $contextObject, $finalClass);
30 49
    }
31
32
33 View Code Duplication
    public function getRules()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        return [
36
            'query'    => ['type' => TypeService::TYPE_OBJECT_TYPE, 'required' => true],
37
            'mutation' => ['type' => TypeService::TYPE_OBJECT_TYPE],
38
            'types'    => ['type' => TypeService::TYPE_ARRAY],
39
            'name'     => ['type' => TypeService::TYPE_STRING],
40
        ];
41
    }
42
43 49
    protected function build()
44
    {
45 49
        parent::build();
46 49
        if (!empty($this->data['types'])) {
47
            $this->typesList->addTypes($this->data['types']);
48
        }
49 49
    }
50
51
52
    /**
53
     * @return AbstractObjectType
54
     */
55 49
    public function getQuery()
56
    {
57 49
        return $this->data['query'];
58
    }
59
60
    /**
61
     * @param $query AbstractObjectType
62
     *
63
     * @return SchemaConfig
64
     */
65 7
    public function setQuery($query)
66
    {
67 7
        $this->data['query'] = $query;
68
69 7
        return $this;
70
    }
71
72
    /**
73
     * @return ObjectType
74
     */
75 41
    public function getMutation()
76
    {
77 41
        return $this->get('mutation');
78
    }
79
80
    /**
81
     * @param $query AbstractObjectType
82
     *
83
     * @return SchemaConfig
84
     */
85
    public function setMutation($query)
86
    {
87
        $this->data['mutation'] = $query;
88
89
        return $this;
90
    }
91
92
    public function getName()
93
    {
94
        return $this->get('name', 'RootSchema');
95
    }
96
97 6
    public function getTypesList()
98
    {
99 6
        return $this->typesList;
100
    }
101
102
}
103