Passed
Push — master ( 319fcb...7a107a )
by Rafael
04:41
created

GraphQLDefinitionPluginManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 1
crap 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Definition\Plugin;
12
13
use Ynlo\GraphQLBundle\Component\TaggedServices\TaggedServices;
14
use Ynlo\GraphQLBundle\Component\TaggedServices\TagSpecification;
15
16
/**
17
 * GraphQLDefinitionPluginManager
18
 */
19
class GraphQLDefinitionPluginManager
20
{
21
    /**
22
     * @var DefinitionPluginInterface[]
23
     */
24
    protected $extensions;
25
26
    /**
27
     * @var bool
28
     */
29
    protected $loaded = false;
30
31
    /**
32
     * @var TaggedServices
33
     */
34
    protected $taggedServices;
35
36
    /**
37
     * ExtensionManager constructor.
38
     *
39
     * @param TaggedServices $taggedServices
40
     */
41
    public function __construct(TaggedServices $taggedServices)
42
    {
43
        $this->taggedServices = $taggedServices;
44
    }
45
46
    /**
47
     * @return array|DefinitionPluginInterface[]
48
     */
49
    public function getExtensions()
50
    {
51
        if ($this->loaded) {
52
            return $this->extensions;
53
        }
54
        $this->extensions = [];
55
56
        /** @var TagSpecification $extensions */
57
        $taggedServices = $this->taggedServices->findTaggedServices('graphql.definition_extension');
58
        foreach ($taggedServices as $tagSpecification) {
59
            /** @var DefinitionPluginInterface $extension */
60
            $extension = $tagSpecification->getService();
61
            $this->extensions[$extension->getName()] = $extension;
62
        }
63
64
        $this->loaded = true;
65
66
        return $this->extensions;
67
    }
68
}
69