InterfaceDefinition::addImplementor()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 8
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
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;
12
13
use Ynlo\GraphQLBundle\Definition\Traits\ClassAwareDefinitionTrait;
14
use Ynlo\GraphQLBundle\Definition\Traits\DefinitionTrait;
15
use Ynlo\GraphQLBundle\Definition\Traits\DeprecateTrait;
16
use Ynlo\GraphQLBundle\Definition\Traits\ExtensionsAwareTrait;
17
use Ynlo\GraphQLBundle\Definition\Traits\FieldsAwareDefinitionTrait;
18
use Ynlo\GraphQLBundle\Definition\Traits\ObjectDefinitionTrait;
19
use Ynlo\GraphQLBundle\Definition\Traits\PolymorphicDefinitionTrait;
20
21
/**
22
 * Class InterfaceDefinition
23
 */
24
class InterfaceDefinition implements ObjectDefinitionInterface, HasExtensionsInterface, PolymorphicDefinitionInterface, DeprecateInterface
25
{
26
    use DefinitionTrait;
27
    use FieldsAwareDefinitionTrait;
28
    use ClassAwareDefinitionTrait;
29
    use ObjectDefinitionTrait;
30
    use ExtensionsAwareTrait;
31
    use PolymorphicDefinitionTrait;
32
    use DeprecateTrait;
33
34
    /**
35
     * @var string[]
36
     */
37
    protected $implementors = [];
38
39
    /**
40
     * @return \string[]
41
     */
42 6
    public function getImplementors(): array
43
    {
44 6
        return $this->implementors;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->implementors returns the type string[] which is incompatible with the documented return type string[].
Loading history...
45
    }
46
47
    /**
48
     * @param string $type
49
     */
50 33
    public function addImplementor($type)
51
    {
52
        //a interface can't be implemented by himself
53 33
        if ($type === $this->name) {
54 32
            return;
55
        }
56
57 33
        $this->implementors[$type] = $type;
58 33
    }
59
60
    /**
61
     * @param string $type
62
     *
63
     * @return $this
64
     */
65 1
    public function removeImplementor($type)
66
    {
67 1
        if (isset($this->implementors[$type])) {
68 1
            unset($this->implementors[$type]);
69
        }
70
71 1
        return $this;
72
    }
73
}
74