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 | namespace EveryPolitician\EveryPoliticianPopolo\Objects; |
||
4 | |||
5 | use \Exception; |
||
6 | use \EveryPolitician\EveryPoliticianPopolo\Parse; |
||
7 | |||
8 | class Person extends PopoloObject |
||
9 | { |
||
10 | use \EveryPolitician\EveryPoliticianPopolo\Traits\ArrayGetterTrait; |
||
11 | |||
12 | protected $properties = [ |
||
13 | 'id', |
||
14 | 'email', |
||
15 | 'gender', |
||
16 | 'honorificPrefix', |
||
17 | 'honorificSuffix', |
||
18 | 'image', |
||
19 | 'name', |
||
20 | 'sortName', |
||
21 | 'nationalIdentity', |
||
22 | 'summary', |
||
23 | 'biography', |
||
24 | 'birthDate', |
||
25 | 'deathDate', |
||
26 | 'familyName', |
||
27 | 'givenName', |
||
28 | 'wikidata', |
||
29 | 'twitter', |
||
30 | 'twitterAll', |
||
31 | 'phone', |
||
32 | 'phoneAll', |
||
33 | 'facebook', |
||
34 | 'facebookAll', |
||
35 | 'fax', |
||
36 | 'faxAll', |
||
37 | |||
38 | 'links', |
||
39 | 'contactDetails', |
||
40 | 'identifiers', |
||
41 | 'images', |
||
42 | 'otherNames', |
||
43 | 'sources', |
||
44 | 'memberships', |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * String representation of {@link Person} |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 6 | public function __toString() |
|
53 | { |
||
54 | 6 | return "<Person: ".$this->name.">"; |
|
0 ignored issues
–
show
|
|||
55 | } |
||
56 | |||
57 | 90 | protected function getId() |
|
58 | { |
||
59 | 90 | return $this->arrGet($this->data, 'id'); |
|
60 | } |
||
61 | |||
62 | 3 | protected function getEmail() |
|
63 | { |
||
64 | 3 | return $this->arrGet($this->data, 'email'); |
|
65 | } |
||
66 | |||
67 | 3 | protected function getGender() |
|
68 | { |
||
69 | 3 | return $this->arrGet($this->data, 'gender'); |
|
70 | } |
||
71 | |||
72 | 3 | protected function getHonorificPrefix() |
|
73 | { |
||
74 | 3 | return $this->arrGet($this->data, 'honorific_prefix'); |
|
75 | } |
||
76 | |||
77 | 3 | protected function getHonorificSuffix() |
|
78 | { |
||
79 | 3 | return $this->arrGet($this->data, 'honorific_suffix'); |
|
80 | } |
||
81 | |||
82 | 6 | protected function getImage() |
|
83 | { |
||
84 | 6 | return $this->arrGet($this->data, 'image'); |
|
85 | } |
||
86 | |||
87 | 33 | protected function getName() |
|
88 | { |
||
89 | 33 | return $this->arrGet($this->data, 'name'); |
|
90 | } |
||
91 | |||
92 | 3 | protected function getSortName() |
|
93 | { |
||
94 | 3 | return $this->arrGet($this->data, 'sort_name'); |
|
95 | } |
||
96 | |||
97 | 3 | protected function getNationalIdentity() |
|
98 | { |
||
99 | 3 | return $this->arrGet($this->data, 'national_identity'); |
|
100 | } |
||
101 | |||
102 | 3 | protected function getSummary() |
|
103 | { |
||
104 | 3 | return $this->arrGet($this->data, 'summary'); |
|
105 | } |
||
106 | |||
107 | 3 | protected function getBiography() |
|
108 | { |
||
109 | 3 | return $this->arrGet($this->data, 'biography'); |
|
110 | } |
||
111 | |||
112 | 6 | protected function getBirthDate() |
|
113 | { |
||
114 | 6 | return $this->getDate('birth_date'); |
|
115 | } |
||
116 | |||
117 | 6 | protected function getDeathDate() |
|
118 | { |
||
119 | 6 | return $this->getDate('death_date'); |
|
120 | } |
||
121 | |||
122 | 3 | protected function getFamilyName() |
|
123 | { |
||
124 | 3 | return $this->arrGet($this->data, 'family_name'); |
|
125 | } |
||
126 | |||
127 | 3 | protected function getGivenName() |
|
128 | { |
||
129 | 3 | return $this->arrGet($this->data, 'given_name'); |
|
130 | } |
||
131 | |||
132 | 3 | protected function getWikidata() |
|
133 | { |
||
134 | 3 | return $this->identifierValue('wikidata'); |
|
135 | } |
||
136 | |||
137 | 9 | protected function getTwitter() |
|
138 | { |
||
139 | 9 | $usernameOrUrl = $this->contactDetailValue('twitter') ?: $this->linkValue('twitter'); |
|
140 | 9 | if ($usernameOrUrl) { |
|
141 | 6 | return Parse::extractTwitterUsername($usernameOrUrl); |
|
142 | } |
||
143 | 3 | return null; |
|
144 | } |
||
145 | |||
146 | 6 | protected function getTwitterAll() |
|
147 | { |
||
148 | // The Twitter screen names in contact_details and links will |
||
149 | // in most cases be the same, so remove duplicates: |
||
150 | 6 | $allTwitters = []; |
|
151 | 6 | $rawTwitters = $this->contactDetailValues('twitter') + $this->linkValues('twitter'); |
|
152 | 6 | foreach ($rawTwitters as $rawTwitter) { |
|
153 | 6 | $twitter = Parse::extractTwitterUsername($rawTwitter); |
|
154 | 6 | if (!in_array($twitter, $allTwitters)) { |
|
155 | 6 | $allTwitters[] = $twitter; |
|
156 | 2 | } |
|
157 | 2 | } |
|
158 | 6 | return $allTwitters; |
|
159 | } |
||
160 | |||
161 | 3 | protected function getPhone() |
|
162 | { |
||
163 | 3 | return $this->contactDetailValue('phone'); |
|
164 | } |
||
165 | |||
166 | 3 | protected function getPhoneAll() |
|
167 | { |
||
168 | 3 | return $this->contactDetailValues('phone'); |
|
169 | } |
||
170 | |||
171 | 3 | protected function getFacebook() |
|
172 | { |
||
173 | 3 | return $this->linkValue('facebook'); |
|
174 | } |
||
175 | |||
176 | 3 | protected function getFacebookAll() |
|
177 | { |
||
178 | 3 | return $this->linkValues('facebook'); |
|
179 | } |
||
180 | |||
181 | 3 | protected function getFax() |
|
182 | { |
||
183 | 3 | return $this->contactDetailValue('fax'); |
|
184 | } |
||
185 | |||
186 | 3 | protected function getFaxAll() |
|
187 | { |
||
188 | 3 | return $this->contactDetailValues('fax'); |
|
189 | } |
||
190 | |||
191 | 3 | protected function getLinks() |
|
192 | { |
||
193 | 3 | return $this->getRelatedObjectArr('links'); |
|
194 | } |
||
195 | |||
196 | 3 | protected function getContactDetails() |
|
197 | { |
||
198 | 3 | return $this->getRelatedObjectArr('contact_details'); |
|
199 | } |
||
200 | |||
201 | 3 | protected function getIdentifiers() |
|
202 | { |
||
203 | 3 | return $this->getRelatedObjectArr('identifiers'); |
|
204 | } |
||
205 | |||
206 | 3 | protected function getImages() |
|
207 | { |
||
208 | 3 | return $this->getRelatedObjectArr('images'); |
|
209 | } |
||
210 | |||
211 | 21 | protected function getOtherNames() |
|
212 | { |
||
213 | 21 | return $this->getRelatedObjectArr('other_names'); |
|
214 | } |
||
215 | |||
216 | 3 | protected function getSources() |
|
217 | { |
||
218 | 3 | return $this->getRelatedObjectArr('sources'); |
|
219 | } |
||
220 | |||
221 | 3 | protected function getMemberships() |
|
222 | { |
||
223 | 3 | $memberships = []; |
|
224 | 3 | foreach ($this->allPopolo->memberships as $m) { |
|
225 | 3 | if ($m->personId == $this->id) { |
|
0 ignored issues
–
show
The property
id does not exist on object<EveryPolitician\E...nPopolo\Objects\Person> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
226 | 3 | $memberships[] = $m; |
|
227 | 1 | } |
|
228 | 1 | } |
|
229 | 3 | return $memberships; |
|
230 | } |
||
231 | |||
232 | 9 | private function isNameCurrentAt($name, $dateStr) |
|
233 | { |
||
234 | 9 | $startRange = $this->arrGet($name, 'start_date') ?: '0001-01-01'; |
|
235 | 9 | $endRange = $this->arrGet($name, 'end_date') ?: '9999-12-31'; |
|
236 | 9 | return $dateStr >= $startRange && $dateStr <= $endRange; |
|
237 | } |
||
238 | |||
239 | 15 | public function nameAt($particularDate) |
|
240 | { |
||
241 | 15 | $historicNames = []; |
|
242 | 15 | foreach ($this->otherNames as $otherName) { |
|
0 ignored issues
–
show
The property
otherNames does not exist on object<EveryPolitician\E...nPopolo\Objects\Person> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
243 | 12 | if (array_key_exists('end_date', $otherName)) { |
|
244 | 11 | $historicNames[] = $otherName; |
|
245 | 3 | } |
|
246 | 5 | } |
|
247 | 15 | if (empty($historicNames)) { |
|
248 | 6 | return $this->name; |
|
0 ignored issues
–
show
The property
name does not exist on object<EveryPolitician\E...nPopolo\Objects\Person> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
249 | } |
||
250 | 9 | $namesAtDate = []; |
|
251 | 9 | foreach ($historicNames as $n) { |
|
252 | 9 | if ($this->isNameCurrentAt($n, $particularDate->format('Y-m-d'))) { |
|
253 | 8 | $namesAtDate[] = $n; |
|
254 | 2 | } |
|
255 | 3 | } |
|
256 | 9 | if (empty($namesAtDate)) { |
|
257 | 3 | return $this->name; |
|
0 ignored issues
–
show
The property
name does not exist on object<EveryPolitician\E...nPopolo\Objects\Person> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
258 | } |
||
259 | 6 | if (count($namesAtDate) > 1) { |
|
260 | 3 | $msg = 'Multiple names for '.(string) $this; |
|
261 | 3 | $msg .= ' found at date '.$particularDate->format('Y-m-d'); |
|
262 | 3 | throw new Exception($msg); |
|
263 | } |
||
264 | 3 | return $namesAtDate[0]['name']; |
|
265 | } |
||
266 | } |
||
267 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.