Test Setup Failed
Push — master ( e8c39a...45e116 )
by Kirill
02:51 queued 12s
created

Execution   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 56
rs 10
c 1
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getArguments() 0 3 1
A getArgument() 0 3 1
A getContext() 0 3 1
A hasArgument() 0 3 2
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\Runtime;
13
14
use GraphQL\Contracts\TypeSystem\DefinitionInterface;
15
16
use function GraphQL\TypeSystem\iterable_to_array;
17
18
/**
19
 * Class Execution
20
 */
21
abstract class Execution implements ExecutionInterface
22
{
23
    /**
24
     * @var DefinitionInterface
25
     */
26
    private DefinitionInterface $context;
27
28
    /**
29
     * @var iterable
30
     */
31
    private iterable $arguments;
32
33
    /**
34
     * Execution constructor.
35
     *
36
     * @param DefinitionInterface $context
37
     * @param iterable $arguments
38
     */
39
    public function __construct(DefinitionInterface $context, iterable $arguments = [])
40
    {
41
        $this->context = $context;
42
        $this->arguments = iterable_to_array($arguments, true);
43
    }
44
45
    /**
46
     * @return DefinitionInterface
47
     */
48
    public function getContext(): DefinitionInterface
49
    {
50
        return $this->context;
51
    }
52
53
    /**
54
     * @return iterable
55
     */
56
    public function getArguments(): iterable
57
    {
58
        return $this->arguments;
59
    }
60
61
    /**
62
     * @param string $name
63
     * @return mixed|null
64
     */
65
    public function getArgument(string $name)
66
    {
67
        return $this->arguments[$name] ?? null;
68
    }
69
70
    /**
71
     * @param string $name
72
     * @return bool
73
     */
74
    public function hasArgument(string $name): bool
75
    {
76
        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

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