@@ -38,7 +38,7 @@ |
||
38 | 38 | $this->maxDepth = $maxDepth; |
39 | 39 | $message = $message ?: 'Referenced entity id lookup failed: Maximum depth of ' . $maxDepth . ' exhausted.'; |
40 | 40 | |
41 | - parent::__construct( $fromId, $propertyId, $toIds, $message, $previous ); |
|
41 | + parent::__construct($fromId, $propertyId, $toIds, $message, $previous); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | private $lookup; |
21 | 21 | |
22 | - public function __construct( EntityLookup $lookup ) { |
|
22 | + public function __construct(EntityLookup $lookup) { |
|
23 | 23 | $this->lookup = $lookup; |
24 | 24 | } |
25 | 25 | |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | * @param EntityId $entityId |
31 | 31 | * @return EntityDocument|null |
32 | 32 | */ |
33 | - public function getEntity( EntityId $entityId ) { |
|
33 | + public function getEntity(EntityId $entityId) { |
|
34 | 34 | try { |
35 | - return $this->lookup->getEntity( $entityId ); |
|
36 | - } catch ( EntityLookupException $exception ) { |
|
35 | + return $this->lookup->getEntity($entityId); |
|
36 | + } catch (EntityLookupException $exception) { |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param EntityId $entityId |
47 | 47 | * @return bool |
48 | 48 | */ |
49 | - public function hasEntity( EntityId $entityId ) { |
|
50 | - return $this->lookup->hasEntity( $entityId ); |
|
49 | + public function hasEntity(EntityId $entityId) { |
|
50 | + return $this->lookup->hasEntity($entityId); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -27,6 +27,6 @@ |
||
27 | 27 | * @throws LabelDescriptionLookupException |
28 | 28 | * @return Term|null |
29 | 29 | */ |
30 | - public function getDescription( EntityId $entityId ); |
|
30 | + public function getDescription(EntityId $entityId); |
|
31 | 31 | |
32 | 32 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private $descriptions; |
34 | 34 | |
35 | - public function __construct( EntityLookup $entityLookup ) { |
|
35 | + public function __construct(EntityLookup $entityLookup) { |
|
36 | 36 | $this->entityLookup = $entityLookup; |
37 | 37 | } |
38 | 38 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | * @return string|null |
46 | 46 | * @throws TermLookupException |
47 | 47 | */ |
48 | - public function getLabel( EntityId $entityId, $languageCode ) { |
|
49 | - $labels = $this->getAllLabels( $entityId, [ $languageCode ] ); |
|
48 | + public function getLabel(EntityId $entityId, $languageCode) { |
|
49 | + $labels = $this->getAllLabels($entityId, [$languageCode]); |
|
50 | 50 | |
51 | - if ( $labels->hasTermForLanguage( $languageCode ) ) { |
|
52 | - return $labels->getByLanguage( $languageCode )->getText(); |
|
51 | + if ($labels->hasTermForLanguage($languageCode)) { |
|
52 | + return $labels->getByLanguage($languageCode)->getText(); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return null; |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * @throws TermLookupException |
65 | 65 | * @return string[] |
66 | 66 | */ |
67 | - public function getLabels( EntityId $entityId, array $languages ) { |
|
68 | - $labels = $this->getAllLabels( $entityId, $languages )->toTextArray(); |
|
67 | + public function getLabels(EntityId $entityId, array $languages) { |
|
68 | + $labels = $this->getAllLabels($entityId, $languages)->toTextArray(); |
|
69 | 69 | |
70 | - return array_intersect_key( $labels, array_flip( $languages ) ); |
|
70 | + return array_intersect_key($labels, array_flip($languages)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | * @throws TermLookupException |
80 | 80 | * @return string|null |
81 | 81 | */ |
82 | - public function getDescription( EntityId $entityId, $languageCode ) { |
|
83 | - $descriptions = $this->getAllDescriptions( $entityId, [ $languageCode ] ); |
|
82 | + public function getDescription(EntityId $entityId, $languageCode) { |
|
83 | + $descriptions = $this->getAllDescriptions($entityId, [$languageCode]); |
|
84 | 84 | |
85 | - if ( $descriptions->hasTermForLanguage( $languageCode ) ) { |
|
86 | - return $descriptions->getByLanguage( $languageCode )->getText(); |
|
85 | + if ($descriptions->hasTermForLanguage($languageCode)) { |
|
86 | + return $descriptions->getByLanguage($languageCode)->getText(); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return null; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @throws TermLookupException |
99 | 99 | * @return string[] |
100 | 100 | */ |
101 | - public function getDescriptions( EntityId $entityId, array $languages ) { |
|
102 | - $descriptions = $this->getAllDescriptions( $entityId, $languages )->toTextArray(); |
|
101 | + public function getDescriptions(EntityId $entityId, array $languages) { |
|
102 | + $descriptions = $this->getAllDescriptions($entityId, $languages)->toTextArray(); |
|
103 | 103 | |
104 | - return array_intersect_key( $descriptions, array_flip( $languages ) ); |
|
104 | + return array_intersect_key($descriptions, array_flip($languages)); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * @throws TermLookupException |
112 | 112 | * @return TermList |
113 | 113 | */ |
114 | - private function getAllLabels( EntityId $entityId, array $languageCodes ) { |
|
114 | + private function getAllLabels(EntityId $entityId, array $languageCodes) { |
|
115 | 115 | $id = $entityId->getSerialization(); |
116 | 116 | |
117 | - if ( !isset( $this->labels[$id] ) ) { |
|
118 | - $entity = $this->fetchEntity( $entityId, $languageCodes ); |
|
117 | + if (!isset($this->labels[$id])) { |
|
118 | + $entity = $this->fetchEntity($entityId, $languageCodes); |
|
119 | 119 | $this->labels[$id] = $entity instanceof LabelsProvider |
120 | 120 | ? $entity->getLabels() |
121 | 121 | : new TermList(); |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @throws TermLookupException |
132 | 132 | * @return TermList |
133 | 133 | */ |
134 | - private function getAllDescriptions( EntityId $entityId, array $languageCodes ) { |
|
134 | + private function getAllDescriptions(EntityId $entityId, array $languageCodes) { |
|
135 | 135 | $id = $entityId->getSerialization(); |
136 | 136 | |
137 | - if ( !isset( $this->descriptions[$id] ) ) { |
|
138 | - $entity = $this->fetchEntity( $entityId, $languageCodes ); |
|
137 | + if (!isset($this->descriptions[$id])) { |
|
138 | + $entity = $this->fetchEntity($entityId, $languageCodes); |
|
139 | 139 | $this->descriptions[$id] = $entity instanceof DescriptionsProvider |
140 | 140 | ? $entity->getDescriptions() |
141 | 141 | : new TermList(); |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | * @throws TermLookupException |
152 | 152 | * @return EntityDocument |
153 | 153 | */ |
154 | - private function fetchEntity( EntityId $entityId, array $languages ) { |
|
154 | + private function fetchEntity(EntityId $entityId, array $languages) { |
|
155 | 155 | try { |
156 | - $entity = $this->entityLookup->getEntity( $entityId ); |
|
157 | - } catch ( EntityLookupException $ex ) { |
|
158 | - throw new TermLookupException( $entityId, $languages, 'The entity could not be loaded', $ex ); |
|
156 | + $entity = $this->entityLookup->getEntity($entityId); |
|
157 | + } catch (EntityLookupException $ex) { |
|
158 | + throw new TermLookupException($entityId, $languages, 'The entity could not be loaded', $ex); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( $entity === null ) { |
|
162 | - throw new TermLookupException( $entityId, $languages, 'The entity could not be loaded' ); |
|
161 | + if ($entity === null) { |
|
162 | + throw new TermLookupException($entityId, $languages, 'The entity could not be loaded'); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $entity; |
@@ -26,6 +26,6 @@ |
||
26 | 26 | * @throws LabelDescriptionLookupException |
27 | 27 | * @return Term|null |
28 | 28 | */ |
29 | - public function getLabel( EntityId $entityId ); |
|
29 | + public function getLabel(EntityId $entityId); |
|
30 | 30 | |
31 | 31 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * @param string|null $message |
23 | 23 | * @param Exception|null $previous |
24 | 24 | */ |
25 | - public function __construct( $repositoryName, $message = null, ?Exception $previous = null ) { |
|
25 | + public function __construct($repositoryName, $message = null, ?Exception $previous = null) { |
|
26 | 26 | $this->repositoryName = $repositoryName; |
27 | 27 | |
28 | 28 | parent::__construct( |
@@ -30,17 +30,17 @@ |
||
30 | 30 | */ |
31 | 31 | private array $restrictedEntityLookupArray = []; |
32 | 32 | |
33 | - public function __construct( EntityLookup $entityLookup, int $entityAccessLimit ) { |
|
33 | + public function __construct(EntityLookup $entityLookup, int $entityAccessLimit) { |
|
34 | 34 | $this->entityLookup = $entityLookup; |
35 | 35 | $this->entityAccessLimit = $entityAccessLimit; |
36 | 36 | } |
37 | 37 | |
38 | - public function getRestrictedEntityLookup( Parser $parser ): RestrictedEntityLookup { |
|
39 | - $id = spl_object_hash( $parser ); |
|
40 | - if ( !isset( $this->restrictedEntityLookupArray[$id] ) ) { |
|
41 | - $this->restrictedEntityLookupArray[ $id ] = new RestrictedEntityLookup( $this->entityLookup, $this->entityAccessLimit ); |
|
38 | + public function getRestrictedEntityLookup(Parser $parser): RestrictedEntityLookup { |
|
39 | + $id = spl_object_hash($parser); |
|
40 | + if (!isset($this->restrictedEntityLookupArray[$id])) { |
|
41 | + $this->restrictedEntityLookupArray[$id] = new RestrictedEntityLookup($this->entityLookup, $this->entityAccessLimit); |
|
42 | 42 | } |
43 | 43 | |
44 | - return $this->restrictedEntityLookupArray[ $id ]; |
|
44 | + return $this->restrictedEntityLookupArray[$id]; |
|
45 | 45 | } |
46 | 46 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | ) { |
34 | 34 | $this->entityId = $entityId; |
35 | 35 | |
36 | - $codesString = implode( ', ', $languageCodes ); |
|
36 | + $codesString = implode(', ', $languageCodes); |
|
37 | 37 | |
38 | 38 | parent::__construct( |
39 | 39 | $message ?: 'Term lookup failed for: ' . $entityId . ' with language codes: ' . $codesString, |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param string|null $message |
25 | 25 | * @param Exception|null $previous |
26 | 26 | */ |
27 | - public function __construct( EntityId $entityId, $message = null, ?Exception $previous = null ) { |
|
27 | + public function __construct(EntityId $entityId, $message = null, ?Exception $previous = null) { |
|
28 | 28 | $this->entityId = $entityId; |
29 | 29 | |
30 | 30 | parent::__construct( |