This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the xAPI package. |
||
5 | * |
||
6 | * (c) Christian Flothmann <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Xabbuh\XApi\Model; |
||
13 | |||
14 | /** |
||
15 | * An Experience API {@link https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#statement Statement}. |
||
16 | * |
||
17 | * @author Christian Flothmann <[email protected]> |
||
18 | */ |
||
19 | class Statement |
||
20 | { |
||
21 | /** |
||
22 | * @var string The unique identifier |
||
23 | */ |
||
24 | private $id; |
||
25 | |||
26 | /** |
||
27 | * @var Verb $verb The {@link Verb} |
||
28 | */ |
||
29 | private $verb; |
||
30 | |||
31 | /** |
||
32 | * @var Actor The {@link Actor} |
||
33 | */ |
||
34 | private $actor; |
||
35 | |||
36 | /** |
||
37 | * @var Object The {@link Object} |
||
38 | */ |
||
39 | private $object; |
||
40 | |||
41 | /** |
||
42 | * @var Result The {@link Activity} {@link Result} |
||
43 | */ |
||
44 | private $result; |
||
45 | |||
46 | /** |
||
47 | * @var Actor The Authority that asserted the Statement true |
||
48 | */ |
||
49 | private $authority; |
||
50 | |||
51 | /** |
||
52 | * @var \DateTime The timestamp of when the events described in this statement occurred |
||
53 | */ |
||
54 | private $created; |
||
55 | |||
56 | /** |
||
57 | * @var \DateTime The timestamp of when this statement was recorded by the LRS |
||
58 | */ |
||
59 | private $stored; |
||
60 | |||
61 | public function __construct($id, Actor $actor, Verb $verb, Object $object, Result $result = null, Actor $authority = null, \DateTime $created = null, \DateTime $stored = null) |
||
62 | { |
||
63 | $this->id = $id; |
||
64 | $this->actor = $actor; |
||
65 | $this->verb = $verb; |
||
66 | $this->object = $object; |
||
67 | $this->result = $result; |
||
68 | $this->authority = $authority; |
||
69 | $this->created = $created; |
||
70 | $this->stored = $stored; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Returns the Statement's unique identifier. |
||
75 | * |
||
76 | * @return string The identifier |
||
77 | */ |
||
78 | public function getId() |
||
79 | { |
||
80 | return $this->id; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Returns the Statement's {@link Verb}. |
||
85 | * |
||
86 | * @return Verb The Verb |
||
87 | */ |
||
88 | public function getVerb() |
||
89 | { |
||
90 | return $this->verb; |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Returns the Statement's {@link Actor}. |
||
95 | * |
||
96 | * @return Actor The Actor |
||
97 | */ |
||
98 | public function getActor() |
||
99 | { |
||
100 | return $this->actor; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * Returns the Statement's {@link Object}. |
||
105 | * |
||
106 | * @return \Xabbuh\XApi\Model\Object The Object |
||
107 | */ |
||
108 | public function getObject() |
||
109 | { |
||
110 | return $this->object; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Returns the {@link Activity} {@link Result}. |
||
115 | * |
||
116 | * @return Result The Result |
||
117 | */ |
||
118 | public function getResult() |
||
119 | { |
||
120 | return $this->result; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Returns the Authority that asserted the Statement true. |
||
125 | * |
||
126 | * @return Actor The Authority |
||
127 | */ |
||
128 | public function getAuthority() |
||
129 | { |
||
130 | return $this->authority; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Returns the timestamp of when the events described in this statement |
||
135 | * occurred. |
||
136 | * |
||
137 | * @return \DateTime The timestamp |
||
138 | */ |
||
139 | public function getCreated() |
||
140 | { |
||
141 | return $this->created; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Returns the timestamp of when this statement was recorded by the LRS. |
||
146 | * |
||
147 | * @return \DateTime The timestamp |
||
148 | */ |
||
149 | public function getStored() |
||
150 | { |
||
151 | return $this->stored; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * Tests whether or not this Statement is a void Statement (i.e. it voids |
||
156 | * another Statement). |
||
157 | * |
||
158 | * @return bool True if the Statement voids another Statement, false otherwise |
||
159 | */ |
||
160 | public function isVoidStatement() |
||
161 | { |
||
162 | return $this->verb->isVoidVerb(); |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * Returns a {@link StatementReference} for the Statement. |
||
167 | * |
||
168 | * @return StatementReference The reference |
||
169 | */ |
||
170 | public function getStatementReference() |
||
171 | { |
||
172 | $reference = new StatementReference($this->id); |
||
173 | |||
174 | return $reference; |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * Returns a Statement that voids the current Statement. |
||
179 | * |
||
180 | * @param Actor $actor The Actor voiding this Statement |
||
181 | * |
||
182 | * @return Statement The voiding Statement |
||
183 | */ |
||
184 | public function getVoidStatement(Actor $actor) |
||
185 | { |
||
186 | return new Statement( |
||
187 | null, |
||
188 | $actor, |
||
189 | Verb::createVoidVerb(), |
||
190 | $this->getStatementReference() |
||
191 | ); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * Creates a new Statement based on the current one containing an Authority |
||
196 | * that asserts the Statement true. |
||
197 | * |
||
198 | * @param Actor $authority The Authority asserting the Statement true |
||
199 | * |
||
200 | * @return Statement The new Statement |
||
201 | */ |
||
202 | public function withAuthority(Actor $authority) |
||
203 | { |
||
204 | return new Statement($this->id, $this->actor, $this->verb, $this->object, $this->result, $authority); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * Checks if another statement is equal. |
||
209 | * |
||
210 | * Two statements are equal if and only if all of their properties are equal. |
||
211 | * |
||
212 | * @param Statement $statement The statement to compare with |
||
213 | * |
||
214 | * @return bool True if the statements are equal, false otherwise |
||
215 | */ |
||
216 | public function equals(Statement $statement) |
||
217 | { |
||
218 | if ($this->id !== $statement->id) { |
||
219 | return false; |
||
220 | } |
||
221 | |||
222 | if (!$this->actor->equals($statement->actor)) { |
||
223 | return false; |
||
224 | } |
||
225 | |||
226 | if (!$this->verb->equals($statement->verb)) { |
||
227 | return false; |
||
228 | } |
||
229 | |||
230 | if (!$this->object->equals($statement->object)) { |
||
231 | return false; |
||
232 | } |
||
233 | |||
234 | if (null === $this->result && null !== $statement->result) { |
||
235 | return false; |
||
236 | } |
||
237 | |||
238 | if (null !== $this->result && null === $statement->result) { |
||
239 | return false; |
||
240 | } |
||
241 | |||
242 | View Code Duplication | if (null !== $this->result && !$this->result->equals($statement->result)) { |
|
0 ignored issues
–
show
|
|||
243 | return false; |
||
244 | } |
||
245 | |||
246 | if (null === $this->authority && null !== $statement->authority) { |
||
247 | return false; |
||
248 | } |
||
249 | |||
250 | if (null !== $this->authority && null === $statement->authority) { |
||
251 | return false; |
||
252 | } |
||
253 | |||
254 | if (null !== $this->authority && !$this->authority->equals($statement->authority)) { |
||
255 | return false; |
||
256 | } |
||
257 | |||
258 | return true; |
||
259 | } |
||
260 | } |
||
261 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.