@@ -57,6 +57,9 @@ |
||
| 57 | 57 | return $this->getRelatedObjectArr('identifiers'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param \DateTime $when |
|
| 62 | + */ |
|
| 60 | 63 | public function currentAt($when) |
| 61 | 64 | { |
| 62 | 65 | return ($when >= $this->startDate && $when <= $this->endDate); |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | protected function getName() |
| 24 | 24 | { |
| 25 | - return $this->arrGet($this->data, 'name'); |
|
| 25 | + return $this->arrGet($this->data, 'name'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | protected function getClassification() |
| 29 | 29 | { |
| 30 | - return $this->arrGet($this->data, 'classification'); |
|
| 30 | + return $this->arrGet($this->data, 'classification'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | protected function getStartDate() |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | protected function getOrganizationId() |
| 46 | 46 | { |
| 47 | - return $this->arrGet($this->data, 'organization_id'); |
|
| 47 | + return $this->arrGet($this->data, 'organization_id'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | protected function getOrganization() |
| 51 | 51 | { |
| 52 | - return $this->allPopolo->organizations->lookupFromKey[$this->organizationId]; |
|
| 52 | + return $this->allPopolo->organizations->lookupFromKey[$this->organizationId]; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | protected function getIdentifiers() |
@@ -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, []); |
@@ -40,12 +40,12 @@ |
||
| 40 | 40 | |
| 41 | 41 | protected function getId() |
| 42 | 42 | { |
| 43 | - return $this->arrGet($this->data, 'id'); |
|
| 43 | + return $this->arrGet($this->data, 'id'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | protected function getKeyForHash() |
| 47 | 47 | { |
| 48 | - return $this->getId(); |
|
| 48 | + return $this->getId(); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | private function getRelatedObjects($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]; |
@@ -19,22 +19,22 @@ |
||
| 19 | 19 | |
| 20 | 20 | protected function getName() |
| 21 | 21 | { |
| 22 | - return $this->arrGet($this->data, 'name'); |
|
| 22 | + return $this->arrGet($this->data, 'name'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | protected function getType() |
| 26 | 26 | { |
| 27 | - return $this->arrGet($this->data, 'type'); |
|
| 27 | + return $this->arrGet($this->data, 'type'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | protected function getIdentifiers() |
| 31 | 31 | { |
| 32 | - return $this->getRelatedObjectArr('identifiers'); |
|
| 32 | + return $this->getRelatedObjectArr('identifiers'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | protected function getOtherNames() |
| 36 | 36 | { |
| 37 | - return $this->getRelatedObjectArr('other_names'); |
|
| 37 | + return $this->getRelatedObjectArr('other_names'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | protected function getWikidata() |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function getLabel() |
| 14 | 14 | { |
| 15 | - return $this->arrGet($this->data, 'label'); |
|
| 15 | + return $this->arrGet($this->data, 'label'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | protected function getOrganizationId() |
@@ -47,52 +47,52 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | protected function getEmail() |
| 49 | 49 | { |
| 50 | - return $this->arrGet($this->data, 'email'); |
|
| 50 | + return $this->arrGet($this->data, 'email'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | protected function getGender() |
| 54 | 54 | { |
| 55 | - return $this->arrGet($this->data, 'gender'); |
|
| 55 | + return $this->arrGet($this->data, 'gender'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | protected function getHonorificPrefix() |
| 59 | 59 | { |
| 60 | - return $this->arrGet($this->data, 'honorific_prefix'); |
|
| 60 | + return $this->arrGet($this->data, 'honorific_prefix'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | protected function getHonorificSuffix() |
| 64 | 64 | { |
| 65 | - return $this->arrGet($this->data, 'honorific_suffix'); |
|
| 65 | + return $this->arrGet($this->data, 'honorific_suffix'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | protected function getImage() |
| 69 | 69 | { |
| 70 | - return $this->arrGet($this->data, 'image'); |
|
| 70 | + return $this->arrGet($this->data, 'image'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function getName() |
| 74 | 74 | { |
| 75 | - return $this->arrGet($this->data, 'name'); |
|
| 75 | + return $this->arrGet($this->data, 'name'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | protected function getSortName() |
| 79 | 79 | { |
| 80 | - return $this->arrGet($this->data, 'sort_name'); |
|
| 80 | + return $this->arrGet($this->data, 'sort_name'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | protected function getNationalIdentity() |
| 84 | 84 | { |
| 85 | - return $this->arrGet($this->data, 'national_identity'); |
|
| 85 | + return $this->arrGet($this->data, 'national_identity'); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | protected function getSummary() |
| 89 | 89 | { |
| 90 | - return $this->arrGet($this->data, 'summary'); |
|
| 90 | + return $this->arrGet($this->data, 'summary'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | protected function getBiography() |
| 94 | 94 | { |
| 95 | - return $this->arrGet($this->data, 'biography'); |
|
| 95 | + return $this->arrGet($this->data, 'biography'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | protected function getBirthDate() |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | protected function getFamilyName() |
| 109 | 109 | { |
| 110 | - return $this->arrGet($this->data, 'family_name'); |
|
| 110 | + return $this->arrGet($this->data, 'family_name'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | protected function getGivenName() |
| 114 | 114 | { |
| 115 | - return $this->arrGet($this->data, 'given_name'); |
|
| 115 | + return $this->arrGet($this->data, 'given_name'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | protected function getWikidata() |
@@ -185,32 +185,32 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | protected function getLinks() |
| 187 | 187 | { |
| 188 | - return $this->getRelatedObjectArr('links'); |
|
| 188 | + return $this->getRelatedObjectArr('links'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | protected function getContactDetails() |
| 192 | 192 | { |
| 193 | - return $this->getRelatedObjectArr('contact_details'); |
|
| 193 | + return $this->getRelatedObjectArr('contact_details'); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | protected function getIdentifiers() |
| 197 | 197 | { |
| 198 | - return $this->getRelatedObjectArr('identifiers'); |
|
| 198 | + return $this->getRelatedObjectArr('identifiers'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | protected function getImages() |
| 202 | 202 | { |
| 203 | - return $this->getRelatedObjectArr('images'); |
|
| 203 | + return $this->getRelatedObjectArr('images'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | protected function getOtherNames() |
| 207 | 207 | { |
| 208 | - return $this->getRelatedObjectArr('other_names'); |
|
| 208 | + return $this->getRelatedObjectArr('other_names'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | protected function getSources() |
| 212 | 212 | { |
| 213 | - return $this->getRelatedObjectArr('sources'); |
|
| 213 | + return $this->getRelatedObjectArr('sources'); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | protected function getMemberships() |
@@ -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']; |