|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of Railt package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Railt\SDL\Base\Invocations; |
|
11
|
|
|
|
|
12
|
|
|
use Railt\SDL\Base\Dependent\BaseDependent; |
|
13
|
|
|
use Railt\SDL\Base\Invocations\Argument\HasPassedArguments; |
|
14
|
|
|
use Railt\SDL\Contracts\Invocations\InputInvocation; |
|
15
|
|
|
use Railt\SDL\Contracts\Type; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class BaseInputInvocation |
|
19
|
|
|
*/ |
|
20
|
|
|
abstract class BaseInputInvocation extends BaseDependent implements InputInvocation |
|
21
|
|
|
{ |
|
22
|
|
|
use HasPassedArguments; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Directive type name |
|
26
|
|
|
*/ |
|
27
|
|
|
protected const TYPE_NAME = Type::INPUT_INVOCATION; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return iterable |
|
31
|
|
|
*/ |
|
32
|
588 |
|
public function getIterator(): iterable |
|
33
|
|
|
{ |
|
34
|
588 |
|
return new \ArrayIterator($this->arguments); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param mixed $offset |
|
39
|
|
|
* @return bool |
|
40
|
|
|
*/ |
|
41
|
18 |
|
public function offsetExists($offset): bool |
|
42
|
|
|
{ |
|
43
|
18 |
|
return $this->hasPassedArgument($offset); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param mixed $offset |
|
48
|
|
|
* @return mixed |
|
49
|
|
|
*/ |
|
50
|
18 |
|
public function offsetGet($offset) |
|
51
|
|
|
{ |
|
52
|
18 |
|
return $this->getPassedArgument($offset); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param mixed $offset |
|
57
|
|
|
* @param mixed $value |
|
58
|
|
|
* @return void |
|
59
|
|
|
* @throws \BadMethodCallException |
|
60
|
|
|
*/ |
|
61
|
|
|
public function offsetSet($offset, $value): void |
|
62
|
|
|
{ |
|
63
|
|
|
$error = 'Changing the value of "%s" is not available. Can not change immutable data-set'; |
|
64
|
|
|
throw new \BadMethodCallException(\sprintf($error, $offset)); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param mixed $offset |
|
69
|
|
|
* @return void |
|
70
|
|
|
* @throws \BadMethodCallException |
|
71
|
|
|
*/ |
|
72
|
|
|
public function offsetUnset($offset): void |
|
73
|
|
|
{ |
|
74
|
|
|
$error = 'Removing the "%s" is not available. Can not change immutable data-set'; |
|
75
|
|
|
throw new \BadMethodCallException(\sprintf($error, $offset)); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return array |
|
80
|
|
|
*/ |
|
81
|
|
|
public function jsonSerialize(): array |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->arguments; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|