ArgumentAwareTrait::getArgument()   A
last analyzed

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
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
use Ynlo\GraphQLBundle\Definition\ArgumentAwareInterface;
14
use Ynlo\GraphQLBundle\Definition\ArgumentDefinition;
15
16
/**
17
 * Trait ArgumentAwareTrait
18
 */
19
trait ArgumentAwareTrait
20
{
21
    /**
22
     * @var ArgumentDefinition[]
23
     */
24
    protected $arguments = [];
25
26
    /**
27
     * @return ArgumentDefinition[]
28
     */
29 5
    public function getArguments(): array
30
    {
31 5
        return $this->arguments;
32
    }
33
34
    /**
35
     * @param ArgumentDefinition[] $arguments
36
     *
37
     * @return ArgumentAwareInterface
38
     */
39 1
    public function setArguments(array $arguments): ArgumentAwareInterface
40
    {
41 1
        $this->arguments = $arguments;
42
43 1
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...aits\ArgumentAwareTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Defin...\ArgumentAwareInterface.
Loading history...
44
    }
45
46
    /**
47
     * @param string $name
48
     *
49
     * @return ArgumentDefinition
50
     */
51 7
    public function getArgument(string $name): ArgumentDefinition
52
    {
53 7
        return $this->arguments[$name];
54
    }
55
56
    /**
57
     * @param string $name
58
     *
59
     * @return boolean
60
     */
61 4
    public function hasArgument(string $name): bool
62
    {
63 4
        return array_key_exists($name, $this->arguments);
64
    }
65
66
    /**
67
     * @param ArgumentDefinition $argument
68
     *
69
     * @return ArgumentAwareInterface
70
     */
71 32
    public function addArgument(ArgumentDefinition $argument): ArgumentAwareInterface
72
    {
73 32
        $this->arguments[$argument->getName()] = $argument;
74
75 32
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...aits\ArgumentAwareTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Defin...\ArgumentAwareInterface.
Loading history...
76
    }
77
78
    /**
79
     * @param string $name
80
     *
81
     * @return ArgumentAwareInterface
82
     */
83
    public function removeArgument(string $name): ArgumentAwareInterface
84
    {
85
        unset($this->arguments[$name]);
86
87
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...aits\ArgumentAwareTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Defin...\ArgumentAwareInterface.
Loading history...
88
    }
89
}
90