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

InterfacesAwareTrait::addInterface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 1
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\Traits;
12
13
/**
14
 * InterfacesAwareTrait
15
 */
16
trait InterfacesAwareTrait
17
{
18
    /**
19
     * @var string[]
20
     */
21
    protected $interfaces = [];
22
23
    /**
24
     * @return string[]
25
     */
26 22
    public function getInterfaces(): array
27
    {
28 22
        return $this->interfaces;
29
    }
30
31
    /**
32
     * @param string $name
33
     */
34 1
    public function addInterface(string $name)
35
    {
36 1
        $this->interfaces[] = $name;
37 1
    }
38
39
    /**
40
     * @param string $name
41
     *
42
     * @return $this
43
     */
44
    public function removeInterface(string $name)
45
    {
46
        foreach ($this->interfaces as $index => $interface) {
47
            if ($interface === $name) {
48
                unset($this->interfaces[$index]);
49
                break;
50
            }
51
        }
52
53
        return $this;
54
    }
55
}
56