1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is a part of graphql-youshido project. |
4
|
|
|
* |
5
|
|
|
* @author Alexandr Viniychuk <[email protected]> |
6
|
|
|
* created: 11/30/15 1:30 AM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Youshido\GraphQL\Config\Field; |
10
|
|
|
|
11
|
|
|
use Youshido\GraphQL\Config\AbstractConfig; |
12
|
|
|
use Youshido\GraphQL\Config\Traits\ArgumentsAwareConfigTrait; |
13
|
|
|
use Youshido\GraphQL\Type\Object\AbstractObjectType; |
14
|
|
|
use Youshido\GraphQL\Type\TypeInterface; |
15
|
|
|
use Youshido\GraphQL\Type\TypeService; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class FieldConfig |
19
|
|
|
* @package Youshido\GraphQL\Config\Field |
20
|
|
|
* @method $this setDescription(string $description) |
21
|
|
|
* @method $this setCost(int $cost) |
22
|
|
|
*/ |
23
|
|
|
class FieldConfig extends AbstractConfig |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
use ArgumentsAwareConfigTrait; |
27
|
|
|
|
28
|
80 |
View Code Duplication |
public function getRules() |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
return [ |
31
|
80 |
|
'name' => ['type' => TypeService::TYPE_STRING, 'final' => true], |
32
|
80 |
|
'type' => ['type' => TypeService::TYPE_GRAPHQL_TYPE, 'final' => true], |
33
|
80 |
|
'args' => ['type' => TypeService::TYPE_ARRAY], |
34
|
80 |
|
'description' => ['type' => TypeService::TYPE_STRING], |
35
|
80 |
|
'resolve' => ['type' => TypeService::TYPE_CALLABLE], |
36
|
80 |
|
'isDeprecated' => ['type' => TypeService::TYPE_BOOLEAN], |
37
|
80 |
|
'deprecationReason' => ['type' => TypeService::TYPE_STRING], |
38
|
80 |
|
'cost' => ['type' => TypeService::TYPE_ANY] |
39
|
80 |
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
105 |
|
protected function build() |
43
|
|
|
{ |
44
|
105 |
|
$this->buildArguments(); |
45
|
105 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return TypeInterface|AbstractObjectType |
49
|
|
|
*/ |
50
|
1 |
|
public function getType() |
51
|
|
|
{ |
52
|
1 |
|
return $this->data['type']; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
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.