@@ -53,6 +53,9 @@ discard block |
||
| 53 | 53 | return $this->arrGet($this->data, $popoloArray, []); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** |
|
| 57 | + * @param string $attr |
|
| 58 | + */ |
|
| 56 | 59 | protected function getDate($attr, $default = null) |
| 57 | 60 | { |
| 58 | 61 | $d = $this->arrGet($this->data, $attr); |
@@ -62,6 +65,11 @@ discard block |
||
| 62 | 65 | return $default; |
| 63 | 66 | } |
| 64 | 67 | |
| 68 | + /** |
|
| 69 | + * @param string $popoloArray |
|
| 70 | + * @param string $infoTypeKey |
|
| 71 | + * @param string $infoValueKey |
|
| 72 | + */ |
|
| 65 | 73 | private function getRelatedValues($popoloArray, $infoTypeKey, $infoType, $infoValueKey) |
| 66 | 74 | { |
| 67 | 75 | /* Get a value from one of the Popolo related objects |
@@ -106,6 +114,9 @@ discard block |
||
| 106 | 114 | return $this->getRelatedValues('identifiers', 'scheme', $scheme, 'identifier'); |
| 107 | 115 | } |
| 108 | 116 | |
| 117 | + /** |
|
| 118 | + * @param string $scheme |
|
| 119 | + */ |
|
| 109 | 120 | public function identifierValue($scheme) |
| 110 | 121 | { |
| 111 | 122 | $identifierValues = $this->identifierValues($scheme); |
@@ -117,6 +128,9 @@ discard block |
||
| 117 | 128 | return $this->getRelatedValues('links', 'note', $note, 'url'); |
| 118 | 129 | } |
| 119 | 130 | |
| 131 | + /** |
|
| 132 | + * @param string $note |
|
| 133 | + */ |
|
| 120 | 134 | public function linkValue($note) |
| 121 | 135 | { |
| 122 | 136 | $linkValues = $this->linkValues($note); |
@@ -128,6 +142,9 @@ discard block |
||
| 128 | 142 | return $this->getRelatedValues('contact_details', 'type', $contactType, 'value'); |
| 129 | 143 | } |
| 130 | 144 | |
| 145 | + /** |
|
| 146 | + * @param string $contactType |
|
| 147 | + */ |
|
| 131 | 148 | public function contactDetailValue($contactType) |
| 132 | 149 | { |
| 133 | 150 | $contactDetailValues = $this->contactDetailValues($contactType); |
@@ -142,6 +159,9 @@ discard block |
||
| 142 | 159 | throw new \BadMethodCallException; |
| 143 | 160 | } |
| 144 | 161 | |
| 162 | + /** |
|
| 163 | + * @param string $popoloArray |
|
| 164 | + */ |
|
| 145 | 165 | public function getRelatedObjectArr($popoloArray) |
| 146 | 166 | { |
| 147 | 167 | return $this->arrGet($this->data, $popoloArray, []); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $properties = array_merge($this->baseProperties, $this->properties); |
| 34 | 34 | if (in_array($prop, $properties)) { |
| 35 | - $getter = 'get' . ucfirst($prop); |
|
| 35 | + $getter = 'get'.ucfirst($prop); |
|
| 36 | 36 | return $this->$getter(); |
| 37 | 37 | } |
| 38 | 38 | trigger_error('Undefined property: '.__CLASS__.'::$'.$prop, E_USER_ERROR); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __get($prop) |
| 30 | 30 | { |
| 31 | 31 | if (in_array($prop, $this->properties)) { |
| 32 | - $getter = 'get' . ucfirst($prop); |
|
| 32 | + $getter = 'get'.ucfirst($prop); |
|
| 33 | 33 | return $this->$getter(); |
| 34 | 34 | } |
| 35 | 35 | trigger_error('Undefined property: '.__CLASS__.'::$'.$prop, E_USER_ERROR); |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | $matches = $this->filter($filters); |
| 64 | 64 | $n = count($matches); |
| 65 | 65 | if ($n == 0) { |
| 66 | - $msg = "No " . $this->objectClass . " found matching " . json_encode($filters); |
|
| 66 | + $msg = "No ".$this->objectClass." found matching ".json_encode($filters); |
|
| 67 | 67 | throw new Exceptions\ObjectDoesNotExistException($msg); |
| 68 | 68 | } elseif ($n > 1) { |
| 69 | - $msg = "Multiple " . $this->objectClass . " objects ($n) found matching " . json_encode($filters); |
|
| 69 | + $msg = "Multiple ".$this->objectClass." objects ($n) found matching ".json_encode($filters); |
|
| 70 | 70 | throw new Exceptions\MultipleObjectsReturnedException($msg); |
| 71 | 71 | } |
| 72 | 72 | return $matches[0]; |
@@ -252,8 +252,8 @@ |
||
| 252 | 252 | return $this->name; |
| 253 | 253 | } |
| 254 | 254 | if (count($namesAtDate) > 1) { |
| 255 | - $msg = 'Multiple names for ' . (string) $this; |
|
| 256 | - $msg .= ' found at date ' . $particularDate->format('Y-m-d'); |
|
| 255 | + $msg = 'Multiple names for '.(string) $this; |
|
| 256 | + $msg .= ' found at date '.$particularDate->format('Y-m-d'); |
|
| 257 | 257 | throw new \Exception($msg); |
| 258 | 258 | } |
| 259 | 259 | return $namesAtDate[0]['name']; |
@@ -50,57 +50,57 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected function getId() |
| 52 | 52 | { |
| 53 | - return $this->arrGet($this->data, 'id'); |
|
| 53 | + return $this->arrGet($this->data, 'id'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | protected function getEmail() |
| 57 | 57 | { |
| 58 | - return $this->arrGet($this->data, 'email'); |
|
| 58 | + return $this->arrGet($this->data, 'email'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | protected function getGender() |
| 62 | 62 | { |
| 63 | - return $this->arrGet($this->data, 'gender'); |
|
| 63 | + return $this->arrGet($this->data, 'gender'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | protected function getHonorificPrefix() |
| 67 | 67 | { |
| 68 | - return $this->arrGet($this->data, 'honorific_prefix'); |
|
| 68 | + return $this->arrGet($this->data, 'honorific_prefix'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | protected function getHonorificSuffix() |
| 72 | 72 | { |
| 73 | - return $this->arrGet($this->data, 'honorific_suffix'); |
|
| 73 | + return $this->arrGet($this->data, 'honorific_suffix'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | protected function getImage() |
| 77 | 77 | { |
| 78 | - return $this->arrGet($this->data, 'image'); |
|
| 78 | + return $this->arrGet($this->data, 'image'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | protected function getName() |
| 82 | 82 | { |
| 83 | - return $this->arrGet($this->data, 'name'); |
|
| 83 | + return $this->arrGet($this->data, 'name'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | protected function getSortName() |
| 87 | 87 | { |
| 88 | - return $this->arrGet($this->data, 'sort_name'); |
|
| 88 | + return $this->arrGet($this->data, 'sort_name'); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | protected function getNationalIdentity() |
| 92 | 92 | { |
| 93 | - return $this->arrGet($this->data, 'national_identity'); |
|
| 93 | + return $this->arrGet($this->data, 'national_identity'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | protected function getSummary() |
| 97 | 97 | { |
| 98 | - return $this->arrGet($this->data, 'summary'); |
|
| 98 | + return $this->arrGet($this->data, 'summary'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | protected function getBiography() |
| 102 | 102 | { |
| 103 | - return $this->arrGet($this->data, 'biography'); |
|
| 103 | + return $this->arrGet($this->data, 'biography'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | protected function getBirthDate() |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | protected function getFamilyName() |
| 117 | 117 | { |
| 118 | - return $this->arrGet($this->data, 'family_name'); |
|
| 118 | + return $this->arrGet($this->data, 'family_name'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | protected function getGivenName() |
| 122 | 122 | { |
| 123 | - return $this->arrGet($this->data, 'given_name'); |
|
| 123 | + return $this->arrGet($this->data, 'given_name'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | protected function getWikidata() |
@@ -184,32 +184,32 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | protected function getLinks() |
| 186 | 186 | { |
| 187 | - return $this->getRelatedObjectArr('links'); |
|
| 187 | + return $this->getRelatedObjectArr('links'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | protected function getContactDetails() |
| 191 | 191 | { |
| 192 | - return $this->getRelatedObjectArr('contact_details'); |
|
| 192 | + return $this->getRelatedObjectArr('contact_details'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | protected function getIdentifiers() |
| 196 | 196 | { |
| 197 | - return $this->getRelatedObjectArr('identifiers'); |
|
| 197 | + return $this->getRelatedObjectArr('identifiers'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | protected function getImages() |
| 201 | 201 | { |
| 202 | - return $this->getRelatedObjectArr('images'); |
|
| 202 | + return $this->getRelatedObjectArr('images'); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | protected function getOtherNames() |
| 206 | 206 | { |
| 207 | - return $this->getRelatedObjectArr('other_names'); |
|
| 207 | + return $this->getRelatedObjectArr('other_names'); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | protected function getSources() |
| 211 | 211 | { |
| 212 | - return $this->getRelatedObjectArr('sources'); |
|
| 212 | + return $this->getRelatedObjectArr('sources'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | protected function getMemberships() |
@@ -18,12 +18,12 @@ |
||
| 18 | 18 | |
| 19 | 19 | protected function getId() |
| 20 | 20 | { |
| 21 | - return $this->arrGet($this->data, 'id'); |
|
| 21 | + return $this->arrGet($this->data, 'id'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | protected function getLabel() |
| 25 | 25 | { |
| 26 | - return $this->arrGet($this->data, 'label'); |
|
| 26 | + return $this->arrGet($this->data, 'label'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | protected function getOrganizationId() |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | protected function getId() |
| 27 | 27 | { |
| 28 | - return $this->arrGet($this->data, 'id'); |
|
| 28 | + return $this->arrGet($this->data, 'id'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | protected function getName() |
| 32 | 32 | { |
| 33 | - return $this->arrGet($this->data, 'name'); |
|
| 33 | + return $this->arrGet($this->data, 'name'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | protected function getWikidata() |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | protected function getIdentifiers() |
| 68 | 68 | { |
| 69 | - return $this->getRelatedObjectArr('identifiers'); |
|
| 69 | + return $this->getRelatedObjectArr('identifiers'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | protected function getLinks() |
@@ -20,27 +20,27 @@ |
||
| 20 | 20 | |
| 21 | 21 | protected function getId() |
| 22 | 22 | { |
| 23 | - return $this->arrGet($this->data, 'id'); |
|
| 23 | + return $this->arrGet($this->data, 'id'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | protected function getName() |
| 27 | 27 | { |
| 28 | - return $this->arrGet($this->data, 'name'); |
|
| 28 | + return $this->arrGet($this->data, 'name'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | protected function getType() |
| 32 | 32 | { |
| 33 | - return $this->arrGet($this->data, 'type'); |
|
| 33 | + return $this->arrGet($this->data, 'type'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | protected function getIdentifiers() |
| 37 | 37 | { |
| 38 | - return $this->getRelatedObjectArr('identifiers'); |
|
| 38 | + return $this->getRelatedObjectArr('identifiers'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | protected function getOtherNames() |
| 42 | 42 | { |
| 43 | - return $this->getRelatedObjectArr('other_names'); |
|
| 43 | + return $this->getRelatedObjectArr('other_names'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | protected function getWikidata() |
@@ -119,6 +119,9 @@ |
||
| 119 | 119 | return $this->currentAt(new DateTime); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | + /** |
|
| 123 | + * @param DateTime $when |
|
| 124 | + */ |
|
| 122 | 125 | public function currentAt($when) |
| 123 | 126 | { |
| 124 | 127 | return ($when >= $this->startDate && $when <= $this->endDate); |
@@ -119,6 +119,9 @@ |
||
| 119 | 119 | return $this->currentAt(new DateTime); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | + /** |
|
| 123 | + * @param DateTime $when |
|
| 124 | + */ |
|
| 122 | 125 | public function currentAt($when) |
| 123 | 126 | { |
| 124 | 127 | return ($when >= $this->startDate && $when <= $this->endDate); |