-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReaction.php
54 lines (44 loc) · 1.01 KB
/
Reaction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace cncltd\reactions;
/**
* Конкретная реализация реакции
* Class Reaction.
*/
abstract class Reaction implements ReactionCompatible
{
/**
* Параметры реакции.
*
* @var array
*/
private $envParams = [];
public function execute(): void
{
$actions = $this->getActions();
foreach ($actions as $action) {
if ($action->checkNecessity()) {
$action->execute();
if ($action->isHandled()) {
break;
}
}
}
}
public function set($key, $value): void
{
$this->envParams[$key] = $value;
}
public function get($key, $default)
{
return $this->envParams[$key] ?? $default;
}
public function getList(): array
{
return $this->envParams;
}
public function setEnvParams(array $envParams): void
{
$this->envParams = $envParams;
}
}