@@ -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 ) { |
|
69 | + return $this->propertyDataTypeLookup->getDataTypeIdForProperty($propertyId) === $dataType; |
|
70 | + } catch (PropertyDataTypeLookupException) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | } |
@@ -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 ) { |
|
35 | + return $this->lookup->getEntity($entityId); |
|
36 | + } catch (EntityLookupException) { |
|
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 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | private $labelLookup; |
24 | 24 | |
25 | - public function __construct( LabelLookup $labelLookup ) { |
|
25 | + public function __construct(LabelLookup $labelLookup) { |
|
26 | 26 | $this->labelLookup = $labelLookup; |
27 | 27 | } |
28 | 28 | |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return string Plain text |
35 | 35 | */ |
36 | - public function formatEntityId( EntityId $entityId ) { |
|
37 | - $term = $this->lookupEntityLabel( $entityId ); |
|
38 | - if ( $term !== null ) { |
|
36 | + public function formatEntityId(EntityId $entityId) { |
|
37 | + $term = $this->lookupEntityLabel($entityId); |
|
38 | + if ($term !== null) { |
|
39 | 39 | return $term->getText(); |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return Term|null Null if no label was found or the entity does not exist |
50 | 50 | */ |
51 | - protected function lookupEntityLabel( EntityId $entityId ) { |
|
51 | + protected function lookupEntityLabel(EntityId $entityId) { |
|
52 | 52 | try { |
53 | - return $this->labelLookup->getLabel( $entityId ); |
|
54 | - } catch ( LabelDescriptionLookupException ) { |
|
53 | + return $this->labelLookup->getLabel($entityId); |
|
54 | + } catch (LabelDescriptionLookupException) { |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | private $propertyDataTypeLookup; |
23 | 23 | |
24 | - public function __construct( PropertyDataTypeLookup $propertyDataTypeLookup ) { |
|
24 | + public function __construct(PropertyDataTypeLookup $propertyDataTypeLookup) { |
|
25 | 25 | $this->propertyDataTypeLookup = $propertyDataTypeLookup; |
26 | 26 | } |
27 | 27 | |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public function isMatchingDataType( PropertyId $propertyId, $dataType ) { |
|
36 | + public function isMatchingDataType(PropertyId $propertyId, $dataType) { |
|
37 | 37 | try { |
38 | - return $this->findDataTypeIdForProperty( $propertyId ) === $dataType; |
|
39 | - } catch ( PropertyDataTypeLookupException ) { |
|
38 | + return $this->findDataTypeIdForProperty($propertyId) === $dataType; |
|
39 | + } catch (PropertyDataTypeLookupException) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @return string |
48 | 48 | * @throws PropertyDataTypeLookupException |
49 | 49 | */ |
50 | - private function findDataTypeIdForProperty( PropertyId $propertyId ) { |
|
51 | - return $this->propertyDataTypeLookup->getDataTypeIdForProperty( $propertyId ); |
|
50 | + private function findDataTypeIdForProperty(PropertyId $propertyId) { |
|
51 | + return $this->propertyDataTypeLookup->getDataTypeIdForProperty($propertyId); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param PropertyDataTypeLookup $dataTypeLookup |
38 | 38 | * @param string[]|string $dataTypes One or more property data type identifiers. |
39 | 39 | */ |
40 | - public function __construct( PropertyDataTypeLookup $dataTypeLookup, $dataTypes ) { |
|
40 | + public function __construct(PropertyDataTypeLookup $dataTypeLookup, $dataTypes) { |
|
41 | 41 | $this->dataTypeLookup = $dataTypeLookup; |
42 | 42 | $this->dataTypes = (array)$dataTypes; |
43 | 43 | } |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return bool |
51 | 51 | */ |
52 | - public function statementMatches( Statement $statement ) { |
|
52 | + public function statementMatches(Statement $statement) { |
|
53 | 53 | $id = $statement->getPropertyId(); |
54 | 54 | |
55 | 55 | try { |
56 | - $dataType = $this->dataTypeLookup->getDataTypeIdForProperty( $id ); |
|
57 | - } catch ( PropertyDataTypeLookupException ) { |
|
56 | + $dataType = $this->dataTypeLookup->getDataTypeIdForProperty($id); |
|
57 | + } catch (PropertyDataTypeLookupException) { |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | |
61 | - return in_array( $dataType, $this->dataTypes ); |
|
61 | + return in_array($dataType, $this->dataTypes); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | } |
@@ -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 ) { |
|
101 | + } catch (EntityIdParsingException) { |
|
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | } |