@@ -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 | /** |
@@ -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( |
@@ -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( |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | /** @var array<string,true> Entity id serialization => true */ |
| 27 | 27 | private array $entitiesAccessed = []; |
| 28 | 28 | |
| 29 | - public function __construct( EntityLookup $entityLookup, int $entityAccessLimit ) { |
|
| 30 | - if ( $entityAccessLimit < 1 ) { |
|
| 31 | - throw new InvalidArgumentException( '$entityAccessLimit must be a positive integer' ); |
|
| 29 | + public function __construct(EntityLookup $entityLookup, int $entityAccessLimit) { |
|
| 30 | + if ($entityAccessLimit < 1) { |
|
| 31 | + throw new InvalidArgumentException('$entityAccessLimit must be a positive integer'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $this->entityLookup = $entityLookup; |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @throws EntityAccessLimitException |
| 44 | 44 | * @return EntityDocument |
| 45 | 45 | */ |
| 46 | - public function getEntity( EntityId $entityId ) { |
|
| 46 | + public function getEntity(EntityId $entityId) { |
|
| 47 | 47 | $entityIdSerialization = $entityId->getSerialization(); |
| 48 | - if ( !array_key_exists( $entityIdSerialization, $this->entitiesAccessed ) ) { |
|
| 49 | - if ( count( $this->entitiesAccessed ) >= $this->entityAccessLimit ) { |
|
| 48 | + if (!array_key_exists($entityIdSerialization, $this->entitiesAccessed)) { |
|
| 49 | + if (count($this->entitiesAccessed) >= $this->entityAccessLimit) { |
|
| 50 | 50 | throw new EntityAccessLimitException( |
| 51 | 51 | $entityId, |
| 52 | 52 | $this->getEntityAccessCount(), |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->entitiesAccessed[$entityIdSerialization] = true; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - return $this->entityLookup->getEntity( $entityId ); |
|
| 60 | + return $this->entityLookup->getEntity($entityId); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @throws EntityLookupException |
| 67 | 67 | */ |
| 68 | - public function hasEntity( EntityId $entityId ): bool { |
|
| 69 | - return $this->entityLookup->hasEntity( $entityId ); |
|
| 68 | + public function hasEntity(EntityId $entityId): bool { |
|
| 69 | + return $this->entityLookup->hasEntity($entityId); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @since 2.0 |
| 76 | 76 | */ |
| 77 | 77 | public function getEntityAccessCount(): int { |
| 78 | - return count( $this->entitiesAccessed ); |
|
| 78 | + return count($this->entitiesAccessed); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @since 2.0 |
| 94 | 94 | */ |
| 95 | - public function entityHasBeenAccessed( EntityId $entityId ): bool { |
|
| 95 | + public function entityHasBeenAccessed(EntityId $entityId): bool { |
|
| 96 | 96 | $entityIdSerialization = $entityId->getSerialization(); |
| 97 | 97 | |
| 98 | - return array_key_exists( $entityIdSerialization, $this->entitiesAccessed ); |
|
| 98 | + return array_key_exists($entityIdSerialization, $this->entitiesAccessed); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param TermLookup $termLookup |
| 30 | 30 | * @param string $languageCode |
| 31 | 31 | */ |
| 32 | - public function __construct( TermLookup $termLookup, $languageCode ) { |
|
| 32 | + public function __construct(TermLookup $termLookup, $languageCode) { |
|
| 33 | 33 | $this->termLookup = $termLookup; |
| 34 | 34 | $this->languageCode = $languageCode; |
| 35 | 35 | } |
@@ -40,18 +40,18 @@ discard block |
||
| 40 | 40 | * @throws LabelDescriptionLookupException |
| 41 | 41 | * @return Term|null |
| 42 | 42 | */ |
| 43 | - public function getLabel( EntityId $entityId ) { |
|
| 43 | + public function getLabel(EntityId $entityId) { |
|
| 44 | 44 | try { |
| 45 | - $text = $this->termLookup->getLabel( $entityId, $this->languageCode ); |
|
| 46 | - } catch ( TermLookupException $ex ) { |
|
| 47 | - throw new LabelDescriptionLookupException( $entityId, 'Failed to lookup label', $ex ); |
|
| 45 | + $text = $this->termLookup->getLabel($entityId, $this->languageCode); |
|
| 46 | + } catch (TermLookupException $ex) { |
|
| 47 | + throw new LabelDescriptionLookupException($entityId, 'Failed to lookup label', $ex); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ( $text === null ) { |
|
| 50 | + if ($text === null) { |
|
| 51 | 51 | return null; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return new Term( $this->languageCode, $text ); |
|
| 54 | + return new Term($this->languageCode, $text); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | * @throws LabelDescriptionLookupException |
| 61 | 61 | * @return Term|null |
| 62 | 62 | */ |
| 63 | - public function getDescription( EntityId $entityId ) { |
|
| 63 | + public function getDescription(EntityId $entityId) { |
|
| 64 | 64 | try { |
| 65 | - $text = $this->termLookup->getDescription( $entityId, $this->languageCode ); |
|
| 66 | - } catch ( TermLookupException $ex ) { |
|
| 67 | - throw new LabelDescriptionLookupException( $entityId, 'Failed to lookup description', $ex ); |
|
| 65 | + $text = $this->termLookup->getDescription($entityId, $this->languageCode); |
|
| 66 | + } catch (TermLookupException $ex) { |
|
| 67 | + throw new LabelDescriptionLookupException($entityId, 'Failed to lookup description', $ex); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( $text === null ) { |
|
| 70 | + if ($text === null) { |
|
| 71 | 71 | return null; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return new Term( $this->languageCode, $text ); |
|
| 74 | + return new Term($this->languageCode, $text); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | } |