Passed
Pull Request — master (#23)
by Christoffer
02:07 queued 19s
created

InputArgumentsTrait::getArgumentsAsArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\AST\Node;
4
5
use Digia\GraphQL\Util\SerializationInterface;
6
7
trait InputArgumentsTrait
8
{
9
10
    /**
11
     * @var InputValueDefinitionNode[]
12
     */
13
    protected $arguments;
14
15
    /**
16
     * @return bool
17
     */
18
    public function hasArguments(): bool
19
    {
20
        return !empty($this->arguments);
21
    }
22
23
    /**
24
     * @return InputValueDefinitionNode[]
25
     */
26
    public function getArguments(): array
27
    {
28
        return $this->arguments ?? [];
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    public function getArgumentsAsArray(): array
35
    {
36
        return array_map(function (SerializationInterface $node) {
37
            return $node->toArray();
38
        }, $this->arguments);
39
    }
40
41
    /**
42
     * @param array|InputValueDefinitionNode[] $arguments
43
     * @return $this
44
     */
45
    public function setArguments(array $arguments)
46
    {
47
        $this->arguments = $arguments;
48
        return $this;
49
    }
50
}
51