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
![]() |
|||
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
|
|||
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
|
|||
88 | } |
||
89 | } |
||
90 |