|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Overblog\GraphQLBundle\Definition; |
|
6
|
|
|
|
|
7
|
|
|
use function array_key_exists; |
|
8
|
|
|
use function count; |
|
9
|
|
|
|
|
10
|
|
|
class Argument implements ArgumentInterface |
|
11
|
|
|
{ |
|
12
|
|
|
private array $rawArguments = []; |
|
13
|
|
|
|
|
14
|
110 |
|
public function __construct(array $rawArguments = null) |
|
15
|
|
|
{ |
|
16
|
110 |
|
$this->exchangeArray($rawArguments); |
|
17
|
110 |
|
} |
|
18
|
|
|
|
|
19
|
110 |
|
public function exchangeArray(array $array = null): array |
|
20
|
|
|
{ |
|
21
|
110 |
|
$old = $this->rawArguments; |
|
22
|
110 |
|
$this->rawArguments = $array ?? []; |
|
23
|
|
|
|
|
24
|
110 |
|
return $old; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
48 |
|
public function getArrayCopy(): array |
|
28
|
|
|
{ |
|
29
|
48 |
|
return $this->rawArguments; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param int|string $offset |
|
34
|
|
|
*/ |
|
35
|
60 |
|
public function offsetExists($offset): bool |
|
36
|
|
|
{ |
|
37
|
60 |
|
return array_key_exists($offset, $this->rawArguments); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param int|string $offset |
|
42
|
|
|
* |
|
43
|
|
|
* @return mixed|null |
|
44
|
|
|
*/ |
|
45
|
58 |
|
public function offsetGet($offset) |
|
46
|
|
|
{ |
|
47
|
58 |
|
return $this->offsetExists($offset) ? $this->rawArguments[$offset] : null; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param int|string $offset |
|
52
|
|
|
* @param mixed $value |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function offsetSet($offset, $value): void |
|
55
|
|
|
{ |
|
56
|
1 |
|
$this->rawArguments[$offset] = $value; |
|
57
|
1 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param int|string $offset |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function offsetUnset($offset): void |
|
63
|
|
|
{ |
|
64
|
1 |
|
unset($this->rawArguments[$offset]); |
|
65
|
1 |
|
} |
|
66
|
|
|
|
|
67
|
1 |
|
public function count(): int |
|
68
|
|
|
{ |
|
69
|
1 |
|
return count($this->rawArguments); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
3 |
|
public function __get(string $name) |
|
73
|
|
|
{ |
|
74
|
3 |
|
return $this->rawArguments[$name] ?? null; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|