Execution::getArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Backend\Runtime;
13
14
use GraphQL\Contracts\TypeSystem\DefinitionInterface;
15
16
/**
17
 * Class Execution
18
 */
19
abstract class Execution implements ExecutionInterface
20
{
21
    /**
22
     * @var DefinitionInterface
23
     */
24
    private DefinitionInterface $context;
25
26
    /**
27
     * @var iterable
28
     */
29
    private iterable $arguments;
30
31
    /**
32
     * Execution constructor.
33
     *
34
     * @param DefinitionInterface $context
35
     * @param iterable|\Traversable|array $arguments
36
     */
37
    public function __construct(DefinitionInterface $context, iterable $arguments = [])
38
    {
39
        $this->context = $context;
40
41
        foreach ($arguments as $name => $value) {
42
            $this->arguments[$name] = $value;
43
        }
44
    }
45
46
    /**
47
     * @return DefinitionInterface
48
     */
49
    public function getContext(): DefinitionInterface
50
    {
51
        return $this->context;
52
    }
53
54
    /**
55
     * @return iterable
56
     */
57
    public function getArguments(): iterable
58
    {
59
        return $this->arguments;
60
    }
61
62
    /**
63
     * @param string $name
64
     * @return mixed|null
65
     */
66
    public function getArgument(string $name)
67
    {
68
        return $this->arguments[$name] ?? null;
69
    }
70
71
    /**
72
     * @param string $name
73
     * @return bool
74
     */
75
    public function hasArgument(string $name): bool
76
    {
77
        return isset($this->arguments[$name]) || \array_key_exists($name, $this->arguments);
0 ignored issues
show
Bug introduced by
$this->arguments of type iterable is incompatible with the type array expected by parameter $search of array_key_exists(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

77
        return isset($this->arguments[$name]) || \array_key_exists($name, /** @scrutinizer ignore-type */ $this->arguments);
Loading history...
78
    }
79
}
80