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 | * A {@link Statement} included as part of a parent Statement. |
||
16 | * |
||
17 | * @author Christian Flothmann <[email protected]> |
||
18 | */ |
||
19 | final class SubStatement extends Object |
||
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 | public function __construct($id, Actor $actor, Verb $verb, Object $object, Result $result = null) |
||
47 | { |
||
48 | $this->id = $id; |
||
49 | $this->actor = $actor; |
||
50 | $this->verb = $verb; |
||
51 | $this->object = $object; |
||
52 | $this->result = $result; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Returns the Statement's unique identifier. |
||
57 | * |
||
58 | * @return string The identifier |
||
59 | */ |
||
60 | public function getId() |
||
61 | { |
||
62 | return $this->id; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Returns the Statement's {@link Verb}. |
||
67 | * |
||
68 | * @return Verb The Verb |
||
69 | */ |
||
70 | public function getVerb() |
||
71 | { |
||
72 | return $this->verb; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Returns the Statement's {@link Actor}. |
||
77 | * |
||
78 | * @return Actor The Actor |
||
79 | */ |
||
80 | public function getActor() |
||
81 | { |
||
82 | return $this->actor; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Returns the Statement's {@link Object}. |
||
87 | * |
||
88 | * @return \Xabbuh\XApi\Model\Object The Object |
||
89 | */ |
||
90 | public function getObject() |
||
91 | { |
||
92 | return $this->object; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Returns the {@link Activity} {@link Result}. |
||
97 | * |
||
98 | * @return Result The Result |
||
99 | */ |
||
100 | public function getResult() |
||
101 | { |
||
102 | return $this->result; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Tests whether or not this Statement is a void Statement (i.e. it voids |
||
107 | * another Statement). |
||
108 | * |
||
109 | * @return bool True if the Statement voids another Statement, false otherwise |
||
110 | */ |
||
111 | public function isVoidStatement() |
||
112 | { |
||
113 | return $this->verb->isVoidVerb(); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Returns a {@link StatementReference} for the Statement. |
||
118 | * |
||
119 | * @return StatementReference The reference |
||
120 | */ |
||
121 | public function getStatementReference() |
||
122 | { |
||
123 | $reference = new StatementReference($this->id); |
||
124 | |||
125 | return $reference; |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Returns a Statement that voids the current Statement. |
||
130 | * |
||
131 | * @param Actor $actor The Actor voiding this Statement |
||
132 | * |
||
133 | * @return Statement The voiding Statement |
||
134 | */ |
||
135 | public function getVoidStatement(Actor $actor) |
||
136 | { |
||
137 | return new Statement( |
||
138 | null, |
||
139 | $actor, |
||
140 | Verb::createVoidVerb(), |
||
141 | $this->getStatementReference() |
||
142 | ); |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | public function equals(Object $statement) |
||
149 | { |
||
150 | if ('Xabbuh\XApi\Model\SubStatement' !== get_class($statement)) { |
||
151 | return false; |
||
152 | } |
||
153 | |||
154 | /** @var SubStatement $statement */ |
||
155 | |||
156 | if ($this->id !== $statement->id) { |
||
157 | return false; |
||
158 | } |
||
159 | |||
160 | if (!$this->actor->equals($statement->actor)) { |
||
161 | return false; |
||
162 | } |
||
163 | |||
164 | if (!$this->verb->equals($statement->verb)) { |
||
165 | return false; |
||
166 | } |
||
167 | |||
168 | if (!$this->object->equals($statement->object)) { |
||
169 | return false; |
||
170 | } |
||
171 | |||
172 | if (null === $this->result && null !== $statement->result) { |
||
173 | return false; |
||
174 | } |
||
175 | |||
176 | if (null !== $this->result && null === $statement->result) { |
||
177 | return false; |
||
178 | } |
||
179 | |||
180 | View Code Duplication | if (null !== $this->result && !$this->result->equals($statement->result)) { |
|
0 ignored issues
–
show
|
|||
181 | return false; |
||
182 | } |
||
183 | |||
184 | return true; |
||
185 | } |
||
186 | } |
||
187 |
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.