1 | <?php |
||
11 | class Trigger |
||
12 | { |
||
13 | |||
14 | public $allowedOperators = [ |
||
15 | '>', '<', '>=', '<=', '==', '!=' |
||
16 | ]; |
||
17 | |||
18 | /** |
||
19 | * @ORM\Column(type="integer") |
||
20 | * @ORM\Id |
||
21 | * @ORM\GeneratedValue(strategy="AUTO") |
||
22 | */ |
||
23 | private $id; |
||
24 | |||
25 | /** |
||
26 | * @ORM\Column(type="string", length=100) |
||
27 | */ |
||
28 | private $name; |
||
29 | |||
30 | /** |
||
31 | * @return boolean |
||
32 | */ |
||
33 | public function getIsEnabled() |
||
37 | |||
38 | /** |
||
39 | * @param boolean $isEnabled |
||
40 | * @return Trigger |
||
41 | */ |
||
42 | 1 | public function setIsEnabled($isEnabled) |
|
47 | |||
48 | /** |
||
49 | * @ORM\Column(type="boolean") |
||
50 | */ |
||
51 | private $isEnabled = true; |
||
52 | |||
53 | /** |
||
54 | * @ORM\Column(type="string", length = 2) |
||
55 | */ |
||
56 | private $sign; |
||
57 | |||
58 | /** |
||
59 | * @ORM\Column(type="string", length = 100) |
||
60 | */ |
||
61 | private $value; |
||
62 | |||
63 | |||
64 | 1 | public function getExpression() |
|
68 | |||
69 | /** |
||
70 | * @ORM\Column(type="boolean") |
||
71 | */ |
||
72 | private $state = false; |
||
73 | |||
74 | /** |
||
75 | * @var Variable |
||
76 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Variable", inversedBy="triggers") |
||
77 | */ |
||
78 | public $variable; |
||
79 | |||
80 | /** |
||
81 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Action", inversedBy="activateTriggers") |
||
82 | */ |
||
83 | public $onActivate; |
||
84 | |||
85 | /** |
||
86 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Action", inversedBy="deactivateTriggers") |
||
87 | */ |
||
88 | public $onDeactivate; |
||
89 | |||
90 | /** @ORM\Column(type="text") */ |
||
91 | public $activateParams; |
||
92 | /** @ORM\Column(type="text") */ |
||
93 | public $deactivateParams; |
||
94 | |||
95 | /** |
||
96 | * @param $state boolean |
||
97 | * @return Trigger |
||
98 | */ |
||
99 | 1 | public function setState($state) |
|
104 | |||
105 | 1 | public function getState() |
|
109 | |||
110 | /** |
||
111 | * @return mixed |
||
112 | */ |
||
113 | 1 | public function getSign() |
|
117 | |||
118 | /** |
||
119 | * @param mixed $sign |
||
120 | */ |
||
121 | 1 | public function setSign($sign) |
|
125 | |||
126 | /** |
||
127 | * @return mixed |
||
128 | */ |
||
129 | 1 | public function getValue() |
|
133 | |||
134 | /** |
||
135 | * @param mixed $value |
||
136 | */ |
||
137 | 1 | public function setValue($value) |
|
141 | |||
142 | |||
143 | /** |
||
144 | * @return mixed |
||
145 | */ |
||
146 | public function getId() |
||
150 | |||
151 | /** |
||
152 | * @param mixed $id |
||
153 | * @return Trigger |
||
154 | */ |
||
155 | public function setId($id) |
||
160 | |||
161 | /** |
||
162 | * @return mixed |
||
163 | */ |
||
164 | public function getName() |
||
168 | |||
169 | /** |
||
170 | * @param string $name |
||
171 | * @return Trigger |
||
172 | */ |
||
173 | 1 | public function setName($name) |
|
178 | |||
179 | 1 | public function checkState() |
|
192 | |||
193 | /** |
||
194 | * @return Variable |
||
195 | */ |
||
196 | 1 | public function getVariable() |
|
200 | |||
201 | /** |
||
202 | * @param mixed $variable |
||
203 | * @return Trigger |
||
204 | */ |
||
205 | 1 | public function setVariable($variable) |
|
210 | |||
211 | public function __toString() |
||
215 | } |
||
216 |
On one hand,
eval
might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM,eval
prevents some optimization that they perform.