@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param string[]|string $propertyIds One or more property id serializations. |
| 31 | 31 | */ |
| 32 | - public function __construct( $propertyIds ) { |
|
| 32 | + public function __construct($propertyIds) { |
|
| 33 | 33 | $this->propertyIds = (array)$propertyIds; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | - public function statementMatches( Statement $statement ) { |
|
| 43 | + public function statementMatches(Statement $statement) { |
|
| 44 | 44 | $id = $statement->getPropertyId()->getSerialization(); |
| 45 | - return in_array( $id, $this->propertyIds ); |
|
| 45 | + return in_array($id, $this->propertyIds); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | } |
@@ -33,12 +33,12 @@ |
||
| 33 | 33 | * |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - public function newGuid( EntityId $entityId ) { |
|
| 36 | + public function newGuid(EntityId $entityId) { |
|
| 37 | 37 | return $entityId->getSerialization() . StatementGuid::SEPARATOR . $this->baseGenerator->newGuid(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function newStatementId( EntityId $entityId ): StatementGuid { |
|
| 41 | - return new StatementGuid( $entityId, $this->baseGenerator->newGuid() ); |
|
| 40 | + public function newStatementId(EntityId $entityId): StatementGuid { |
|
| 41 | + return new StatementGuid($entityId, $this->baseGenerator->newGuid()); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | private $entityIdParser; |
| 21 | 21 | |
| 22 | - public function __construct( EntityIdParser $entityIdParser ) { |
|
| 22 | + public function __construct(EntityIdParser $entityIdParser) { |
|
| 23 | 23 | $this->entityIdParser = $entityIdParser; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function validate( $guid ) { |
|
| 36 | - if ( !$this->validateFormat( $guid ) ) { |
|
| 35 | + public function validate($guid) { |
|
| 36 | + if (!$this->validateFormat($guid)) { |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $guidParts = explode( StatementGuid::SEPARATOR, $guid ); |
|
| 40 | + $guidParts = explode(StatementGuid::SEPARATOR, $guid); |
|
| 41 | 41 | |
| 42 | - if ( !$this->validateStatementGuidPrefix( $guidParts[0] ) || !$this->validateGuid( $guidParts[1] ) ) { |
|
| 42 | + if (!$this->validateStatementGuidPrefix($guidParts[0]) || !$this->validateGuid($guidParts[1])) { |
|
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return bool |
| 57 | 57 | */ |
| 58 | - public function validateFormat( $guid ) { |
|
| 59 | - if ( !is_string( $guid ) ) { |
|
| 58 | + public function validateFormat($guid) { |
|
| 59 | + if (!is_string($guid)) { |
|
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $keyParts = explode( '$', $guid ); |
|
| 63 | + $keyParts = explode('$', $guid); |
|
| 64 | 64 | |
| 65 | - if ( count( $keyParts ) !== 2 ) { |
|
| 65 | + if (count($keyParts) !== 2) { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return bool |
| 80 | 80 | */ |
| 81 | - private function validateGuid( $guid ) { |
|
| 81 | + private function validateGuid($guid) { |
|
| 82 | 82 | return (bool)preg_match( |
| 83 | 83 | '/^\{?[A-Z\d]{8}-[A-Z\d]{4}-[A-Z\d]{4}-[A-Z\d]{4}-[A-Z\d]{12}\}?\z/i', |
| 84 | 84 | $guid |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - private function validateStatementGuidPrefix( $prefixedId ) { |
|
| 97 | + private function validateStatementGuidPrefix($prefixedId) { |
|
| 98 | 98 | try { |
| 99 | - $this->entityIdParser->parse( $prefixedId ); |
|
| 99 | + $this->entityIdParser->parse($prefixedId); |
|
| 100 | 100 | return true; |
| 101 | - } catch ( EntityIdParsingException $ex ) { |
|
| 101 | + } catch (EntityIdParsingException $ex) { |
|
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | private $propertyDataTypeLookup; |
| 26 | 26 | |
| 27 | - public function __construct( PropertyDataTypeLookup $propertyDataTypeLookup ) { |
|
| 27 | + public function __construct(PropertyDataTypeLookup $propertyDataTypeLookup) { |
|
| 28 | 28 | $this->propertyDataTypeLookup = $propertyDataTypeLookup; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return DataValue[] |
| 38 | 38 | */ |
| 39 | - public function findFromSnaks( array $snaks, $dataType ) { |
|
| 39 | + public function findFromSnaks(array $snaks, $dataType) { |
|
| 40 | 40 | $found = []; |
| 41 | 41 | |
| 42 | - foreach ( $snaks as $snak ) { |
|
| 43 | - if ( $snak instanceof PropertyValueSnak && |
|
| 44 | - $this->isMatchingDataType( $snak->getPropertyId(), $dataType ) |
|
| 42 | + foreach ($snaks as $snak) { |
|
| 43 | + if ($snak instanceof PropertyValueSnak && |
|
| 44 | + $this->isMatchingDataType($snak->getPropertyId(), $dataType) |
|
| 45 | 45 | ) { |
| 46 | 46 | $dataValue = $snak->getDataValue(); |
| 47 | - if ( method_exists( $dataValue, 'getHash' ) ) { |
|
| 47 | + if (method_exists($dataValue, 'getHash')) { |
|
| 48 | 48 | // We can only tag values as found that are |
| 49 | 49 | // hashable. DataValueObject should, but `getDataValue` |
| 50 | 50 | // only returns the `DataValue` interface, which doesn't |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - private function isMatchingDataType( PropertyId $propertyId, $dataType ) { |
|
| 67 | + private function isMatchingDataType(PropertyId $propertyId, $dataType) { |
|
| 68 | 68 | try { |
| 69 | - return $this->propertyDataTypeLookup->getDataTypeIdForProperty( $propertyId ) === $dataType; |
|
| 70 | - } catch ( PropertyDataTypeLookupException $ex ) { |
|
| 69 | + return $this->propertyDataTypeLookup->getDataTypeIdForProperty($propertyId) === $dataType; |
|
| 70 | + } catch (PropertyDataTypeLookupException $ex) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param EntityId ...$ids |
| 31 | 31 | */ |
| 32 | - public function __construct( ...$ids ) { |
|
| 32 | + public function __construct(...$ids) { |
|
| 33 | 33 | $this->entityIds = $ids; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function addEntityId( EntityId $entityId ) { |
|
| 36 | + public function addEntityId(EntityId $entityId) { |
|
| 37 | 37 | $this->entityIds[] = $entityId; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return EntityId[] |
| 46 | 46 | */ |
| 47 | - public function fetchIds( $limit ) { |
|
| 48 | - $entityIds = array_slice( $this->entityIds, $this->offset, $limit ); |
|
| 49 | - $this->offset += count( $entityIds ); |
|
| 47 | + public function fetchIds($limit) { |
|
| 48 | + $entityIds = array_slice($this->entityIds, $this->offset, $limit); |
|
| 49 | + $this->offset += count($entityIds); |
|
| 50 | 50 | return $entityIds; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** @inheritDoc */ |
| 59 | - public function setPosition( $position ) { |
|
| 59 | + public function setPosition($position) { |
|
| 60 | 60 | $this->offset = $position; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @throws InvalidArgumentException |
| 34 | 34 | */ |
| 35 | - public function __construct( EntityIdFormatter $formatter, $escapeCallback ) { |
|
| 36 | - if ( !is_callable( $escapeCallback ) ) { |
|
| 37 | - throw new InvalidArgumentException( '$escapeCallback must be callable' ); |
|
| 35 | + public function __construct(EntityIdFormatter $formatter, $escapeCallback) { |
|
| 36 | + if (!is_callable($escapeCallback)) { |
|
| 37 | + throw new InvalidArgumentException('$escapeCallback must be callable'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $this->formatter = $formatter; |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string Typically wikitext or HTML, depending on the $escapeCallback provided. |
| 50 | 50 | */ |
| 51 | - public function formatEntityId( EntityId $value ) { |
|
| 52 | - $text = $this->formatter->formatEntityId( $value ); |
|
| 53 | - $escaped = ( $this->escapeCallback )( $text ); |
|
| 51 | + public function formatEntityId(EntityId $value) { |
|
| 52 | + $text = $this->formatter->formatEntityId($value); |
|
| 53 | + $escaped = ($this->escapeCallback)($text); |
|
| 54 | 54 | return $escaped; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @throws InvalidArgumentException |
| 35 | 35 | */ |
| 36 | - public function __construct( array $composers ) { |
|
| 37 | - foreach ( $composers as $entityType => $composer ) { |
|
| 38 | - if ( !is_string( $entityType ) || $entityType === '' || !is_callable( $composer ) ) { |
|
| 39 | - throw new InvalidArgumentException( '$composers must map non-empty strings to callables' ); |
|
| 36 | + public function __construct(array $composers) { |
|
| 37 | + foreach ($composers as $entityType => $composer) { |
|
| 38 | + if (!is_string($entityType) || $entityType === '' || !is_callable($composer)) { |
|
| 39 | + throw new InvalidArgumentException('$composers must map non-empty strings to callables'); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -53,15 +53,15 @@ discard block |
||
| 53 | 53 | * object. |
| 54 | 54 | * @return EntityId |
| 55 | 55 | */ |
| 56 | - public function composeEntityId( $entityType, $uniquePart ) { |
|
| 57 | - if ( !isset( $this->composers[$entityType] ) ) { |
|
| 58 | - throw new InvalidArgumentException( 'Unknown entity type ' . $entityType ); |
|
| 56 | + public function composeEntityId($entityType, $uniquePart) { |
|
| 57 | + if (!isset($this->composers[$entityType])) { |
|
| 58 | + throw new InvalidArgumentException('Unknown entity type ' . $entityType); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $id = $this->composers[$entityType]( $uniquePart ); |
|
| 61 | + $id = $this->composers[$entityType]($uniquePart); |
|
| 62 | 62 | |
| 63 | - if ( !( $id instanceof EntityId ) ) { |
|
| 64 | - throw new UnexpectedValueException( 'Composer for ' . $entityType . ' is invalid' ); |
|
| 63 | + if (!($id instanceof EntityId)) { |
|
| 64 | + throw new UnexpectedValueException('Composer for ' . $entityType . ' is invalid'); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $id; |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @return string Plain text |
| 22 | 22 | */ |
| 23 | - public function formatEntityId( EntityId $entityId ) { |
|
| 23 | + public function formatEntityId(EntityId $entityId) { |
|
| 24 | 24 | return $entityId->getSerialization(); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param string $prefix The prefix to be stripped. Stripping is case sensitive. |
| 32 | 32 | * @param EntityIdParser $idParser |
| 33 | 33 | */ |
| 34 | - public function __construct( $prefix, EntityIdParser $idParser ) { |
|
| 34 | + public function __construct($prefix, EntityIdParser $idParser) { |
|
| 35 | 35 | $this->prefix = $prefix; |
| 36 | 36 | $this->idParser = $idParser; |
| 37 | 37 | } |
@@ -47,16 +47,16 @@ discard block |
||
| 47 | 47 | * or the remaining suffix is not a valid entity ID string. |
| 48 | 48 | * @return EntityId |
| 49 | 49 | */ |
| 50 | - public function parse( $idSerialization ) { |
|
| 51 | - $prefixLength = strlen( $this->prefix ); |
|
| 50 | + public function parse($idSerialization) { |
|
| 51 | + $prefixLength = strlen($this->prefix); |
|
| 52 | 52 | |
| 53 | - if ( strncmp( $idSerialization, $this->prefix, $prefixLength ) !== 0 ) { |
|
| 54 | - throw new EntityIdParsingException( 'Missing expected prefix "' . $this->prefix |
|
| 55 | - . '" in "' . $idSerialization . '"' ); |
|
| 53 | + if (strncmp($idSerialization, $this->prefix, $prefixLength) !== 0) { |
|
| 54 | + throw new EntityIdParsingException('Missing expected prefix "' . $this->prefix |
|
| 55 | + . '" in "' . $idSerialization . '"'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $idSerialization = substr( $idSerialization, $prefixLength ); |
|
| 59 | - return $this->idParser->parse( $idSerialization ); |
|
| 58 | + $idSerialization = substr($idSerialization, $prefixLength); |
|
| 59 | + return $this->idParser->parse($idSerialization); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | } |