@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @param EntityDocument ...$entities |
| 37 | 37 | */ |
| 38 | - public function __construct( ...$entities ) { |
|
| 39 | - foreach ( $entities as $entity ) { |
|
| 40 | - $this->addEntity( $entity ); |
|
| 38 | + public function __construct(...$entities) { |
|
| 39 | + foreach ($entities as $entity) { |
|
| 40 | + $this->addEntity($entity); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @throws InvalidArgumentException |
| 48 | 48 | */ |
| 49 | - public function addEntity( EntityDocument $entity ) { |
|
| 50 | - if ( $entity->getId() === null ) { |
|
| 51 | - throw new InvalidArgumentException( 'The entity needs to have an ID' ); |
|
| 49 | + public function addEntity(EntityDocument $entity) { |
|
| 50 | + if ($entity->getId() === null) { |
|
| 51 | + throw new InvalidArgumentException('The entity needs to have an ID'); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $this->entities[$entity->getId()->getSerialization()] = $entity; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @param EntityLookupException $exception |
| 64 | 64 | */ |
| 65 | - public function addException( EntityLookupException $exception ) { |
|
| 65 | + public function addException(EntityLookupException $exception) { |
|
| 66 | 66 | $this->exceptions[$exception->getEntityId()->getSerialization()] = $exception; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | * @throws EntityLookupException |
| 75 | 75 | * @return ?EntityDocument |
| 76 | 76 | */ |
| 77 | - public function getEntity( EntityId $entityId ) { |
|
| 78 | - $this->throwExceptionIfNeeded( $entityId ); |
|
| 77 | + public function getEntity(EntityId $entityId) { |
|
| 78 | + $this->throwExceptionIfNeeded($entityId); |
|
| 79 | 79 | |
| 80 | - if ( array_key_exists( $entityId->getSerialization(), $this->entities ) ) { |
|
| 80 | + if (array_key_exists($entityId->getSerialization(), $this->entities)) { |
|
| 81 | 81 | return $this->entities[$entityId->getSerialization()]; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -92,26 +92,26 @@ discard block |
||
| 92 | 92 | * @throws EntityLookupException |
| 93 | 93 | * @return bool |
| 94 | 94 | */ |
| 95 | - public function hasEntity( EntityId $entityId ) { |
|
| 96 | - $this->throwExceptionIfNeeded( $entityId ); |
|
| 95 | + public function hasEntity(EntityId $entityId) { |
|
| 96 | + $this->throwExceptionIfNeeded($entityId); |
|
| 97 | 97 | |
| 98 | - return array_key_exists( $entityId->getSerialization(), $this->entities ); |
|
| 98 | + return array_key_exists($entityId->getSerialization(), $this->entities); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - private function throwExceptionIfNeeded( EntityId $entityId ) { |
|
| 102 | - if ( array_key_exists( $entityId->getSerialization(), $this->exceptions ) ) { |
|
| 101 | + private function throwExceptionIfNeeded(EntityId $entityId) { |
|
| 102 | + if (array_key_exists($entityId->getSerialization(), $this->exceptions)) { |
|
| 103 | 103 | throw $this->exceptions[$entityId->getSerialization()]; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** @inheritDoc */ |
| 108 | - public function getItemForId( ItemId $itemId ) { |
|
| 109 | - return ( new LegacyAdapterItemLookup( $this ) )->getItemForId( $itemId ); |
|
| 108 | + public function getItemForId(ItemId $itemId) { |
|
| 109 | + return (new LegacyAdapterItemLookup($this))->getItemForId($itemId); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** @inheritDoc */ |
| 113 | - public function getPropertyForId( PropertyId $propertyId ) { |
|
| 114 | - return ( new LegacyAdapterPropertyLookup( $this ) )->getpropertyForId( $propertyId ); |
|
| 113 | + public function getPropertyForId(PropertyId $propertyId) { |
|
| 114 | + return (new LegacyAdapterPropertyLookup($this))->getpropertyForId($propertyId); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | private EntityLookup $lookup; |
| 18 | 18 | |
| 19 | - public function __construct( EntityLookup $lookup ) { |
|
| 19 | + public function __construct(EntityLookup $lookup) { |
|
| 20 | 20 | $this->lookup = $lookup; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * @return Item|null |
| 27 | 27 | * @throws ItemLookupException |
| 28 | 28 | */ |
| 29 | - public function getItemForId( ItemId $itemId ) { |
|
| 29 | + public function getItemForId(ItemId $itemId) { |
|
| 30 | 30 | try { |
| 31 | - return $this->lookup->getEntity( $itemId ); |
|
| 32 | - } catch ( EntityLookupException $ex ) { |
|
| 33 | - throw new ItemLookupException( $itemId, $ex->getMessage(), $ex ); |
|
| 31 | + return $this->lookup->getEntity($itemId); |
|
| 32 | + } catch (EntityLookupException $ex) { |
|
| 33 | + throw new ItemLookupException($itemId, $ex->getMessage(), $ex); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | private int $entityAccessCount; |
| 16 | 16 | private int $entityAccessLimit; |
| 17 | 17 | |
| 18 | - public function __construct( EntityId $entityId, int $entityAccessCount, int $entityAccessLimit ) { |
|
| 18 | + public function __construct(EntityId $entityId, int $entityAccessCount, int $entityAccessLimit) { |
|
| 19 | 19 | parent::__construct( |
| 20 | 20 | $entityId, |
| 21 | 21 | 'Too many entities loaded, must not load more than ' . $entityAccessLimit . ' entities.' |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | private PropertyDataTypeLookup $lookup; |
| 23 | 23 | |
| 24 | - public function __construct( PropertyDataTypeLookup $propertyDataTypeLookup ) { |
|
| 24 | + public function __construct(PropertyDataTypeLookup $propertyDataTypeLookup) { |
|
| 25 | 25 | $this->lookup = $propertyDataTypeLookup; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | * @throws PropertyDataTypeLookupException |
| 33 | 33 | */ |
| 34 | - public function getDataTypeIdForProperty( PropertyId $propertyId ) { |
|
| 34 | + public function getDataTypeIdForProperty(PropertyId $propertyId) { |
|
| 35 | 35 | $serializedId = $propertyId->getSerialization(); |
| 36 | 36 | |
| 37 | - if ( !array_key_exists( $serializedId, $this->propertyIds ) ) { |
|
| 38 | - $this->propertyIds[$serializedId] = $this->lookup->getDataTypeIdForProperty( $propertyId ); |
|
| 37 | + if (!array_key_exists($serializedId, $this->propertyIds)) { |
|
| 38 | + $this->propertyIds[$serializedId] = $this->lookup->getDataTypeIdForProperty($propertyId); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $this->propertyIds[$serializedId]; |
@@ -21,6 +21,6 @@ |
||
| 21 | 21 | * @return Item|null |
| 22 | 22 | * @throws ItemLookupException |
| 23 | 23 | */ |
| 24 | - public function getItemForId( ItemId $itemId ); |
|
| 24 | + public function getItemForId(ItemId $itemId); |
|
| 25 | 25 | |
| 26 | 26 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param string|null $message |
| 20 | 20 | * @param Exception|null $previous |
| 21 | 21 | */ |
| 22 | - public function __construct( PropertyId $propertyId, $message = null, ?Exception $previous = null ) { |
|
| 22 | + public function __construct(PropertyId $propertyId, $message = null, ?Exception $previous = null) { |
|
| 23 | 23 | parent::__construct( |
| 24 | 24 | $propertyId, |
| 25 | 25 | $message ?: 'Property lookup failed for: ' . $propertyId, |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function getPropertyId() { |
| 34 | 34 | $propertyId = $this->getEntityId(); |
| 35 | - if ( !( $propertyId instanceof PropertyId ) ) { |
|
| 36 | - throw new LogicException( 'expected $propertyId to be of type PropertyId' ); |
|
| 35 | + if (!($propertyId instanceof PropertyId)) { |
|
| 36 | + throw new LogicException('expected $propertyId to be of type PropertyId'); |
|
| 37 | 37 | } |
| 38 | 38 | return $propertyId; |
| 39 | 39 | } |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | * @return EntityId[] |
| 25 | 25 | * @throws EntityRedirectLookupException |
| 26 | 26 | */ |
| 27 | - public function getRedirectIds( EntityId $targetId ); |
|
| 27 | + public function getRedirectIds(EntityId $targetId); |
|
| 28 | 28 | |
| 29 | 29 | } |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * @param EntityLookup $entityLookup |
| 32 | 32 | * @param string[] $disabledEntityTypes |
| 33 | 33 | */ |
| 34 | - public function __construct( EntityLookup $entityLookup, array $disabledEntityTypes ) { |
|
| 35 | - Assert::parameterElementType( 'string', $disabledEntityTypes, '$disabledEntityTypes' ); |
|
| 34 | + public function __construct(EntityLookup $entityLookup, array $disabledEntityTypes) { |
|
| 35 | + Assert::parameterElementType('string', $disabledEntityTypes, '$disabledEntityTypes'); |
|
| 36 | 36 | |
| 37 | 37 | $this->entityLookup = $entityLookup; |
| 38 | 38 | $this->disabledEntityTypes = $disabledEntityTypes; |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | * @throws EntityLookupException |
| 47 | 47 | * @return EntityDocument |
| 48 | 48 | */ |
| 49 | - public function getEntity( EntityId $entityId ) { |
|
| 50 | - if ( in_array( $entityId->getEntityType(), $this->disabledEntityTypes ) ) { |
|
| 49 | + public function getEntity(EntityId $entityId) { |
|
| 50 | + if (in_array($entityId->getEntityType(), $this->disabledEntityTypes)) { |
|
| 51 | 51 | throw new EntityLookupException( |
| 52 | 52 | $entityId, |
| 53 | 53 | 'Entity access for this type of entity is disabled: ' . $entityId->getEntityType() |
| 54 | 54 | ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return $this->entityLookup->getEntity( $entityId ); |
|
| 57 | + return $this->entityLookup->getEntity($entityId); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * @return bool |
| 66 | 66 | * @throws EntityLookupException |
| 67 | 67 | */ |
| 68 | - public function hasEntity( EntityId $entityId ) { |
|
| 69 | - return $this->entityLookup->hasEntity( $entityId ); |
|
| 68 | + public function hasEntity(EntityId $entityId) { |
|
| 69 | + return $this->entityLookup->hasEntity($entityId); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | } |
@@ -36,6 +36,6 @@ |
||
| 36 | 36 | * @return EntityId|null Returns null in case none of the target entities are referenced. |
| 37 | 37 | * @throws ReferencedEntityIdLookupException |
| 38 | 38 | */ |
| 39 | - public function getReferencedEntityId( EntityId $fromId, PropertyId $propertyId, array $toIds ); |
|
| 39 | + public function getReferencedEntityId(EntityId $fromId, PropertyId $propertyId, array $toIds); |
|
| 40 | 40 | |
| 41 | 41 | } |