Completed
Push — master ( 186982...2975e7 )
by Rafael
05:12
created

InterfaceDefinition::getImplementors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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