Completed
Push — master ( 3b79f3...426227 )
by Kirill
03:11
created

TypeBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 3 1
A resolve() 0 3 1
A __construct() 0 4 1
A getRegistry() 0 3 1
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Adapters\Webonyx\Builders;
11
12
use GraphQL\Type\Definition\Directive;
13
use GraphQL\Type\Definition\Type;
14
use Railt\Adapters\Webonyx\Registry;
15
use Railt\Reflection\Contracts\Definitions\TypeDefinition;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Contrac...initions\TypeDefinition was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
/**
18
 * Class TypeBuilder
19
 */
20
abstract class TypeBuilder
21
{
22
    /**
23
     * @var TypeDefinition
24
     */
25
    protected $reflection;
26
27
    /**
28
     * @var Registry
29
     */
30
    private $registry;
31
32
    /**
33
     * TypeBuilder constructor.
34
     * @param TypeDefinition $type
35
     * @param Registry $registry
36
     */
37
    public function __construct(TypeDefinition $type, Registry $registry)
38
    {
39
        $this->reflection = $type;
40
        $this->registry   = $registry;
41
    }
42
43
    /**
44
     * @return Registry
45
     */
46
    protected function getRegistry(): Registry
47
    {
48
        return $this->registry;
49
    }
50
51
    /**
52
     * @param string $service
53
     * @return mixed|object
54
     */
55
    protected function resolve(string $service)
56
    {
57
        return $this->registry->getContainer()->make($service);
58
    }
59
60
    /**
61
     * @param TypeDefinition $type
62
     * @return Type|Directive
63
     * @throws \InvalidArgumentException
64
     */
65
    protected function load(TypeDefinition $type)
66
    {
67
        return $this->registry->get($type);
68
    }
69
70
    /**
71
     * @return mixed|Type
72
     */
73
    abstract public function build();
74
}
75