jenkins-bot has submitted this change and it was merged. Change subject: Split method in ByPropertyValueEntityFinder ......................................................................
Split method in ByPropertyValueEntityFinder Change-Id: I7e692d82deb145d0f2f99bbbb8654f5b8413d581 --- M src/Wikibase/Query/ByPropertyValueEntityFinder.php 1 file changed, 30 insertions(+), 2 deletions(-) Approvals: Addshore: Looks good to me, approved jenkins-bot: Verified diff --git a/src/Wikibase/Query/ByPropertyValueEntityFinder.php b/src/Wikibase/Query/ByPropertyValueEntityFinder.php index caf0a5a..a553a0f 100644 --- a/src/Wikibase/Query/ByPropertyValueEntityFinder.php +++ b/src/Wikibase/Query/ByPropertyValueEntityFinder.php @@ -68,14 +68,39 @@ * @throws InvalidArgumentException */ protected function findEntitiesGivenRawArguments( $propertyIdString, $valueString, $limit, $offset ) { + $this->assertIsValidLimit( $limit ); + $this->assertIsValidOffset( $offset ); + + $value = $this->getValueFromString( $valueString ); + $propertyId = $this->getPropertyIdFromString( $propertyIdString ); + + return $this->findByPropertyValue( $propertyId, $value, $limit, $offset ); + } + + protected function assertIsValidLimit( $limit ) { if ( !is_string( $limit ) || !ctype_digit( $limit ) || (int)$limit < 1 ) { throw new InvalidArgumentException( '$limit needs to be a string representing a strictly positive integer' ); } + } + protected function assertIsValidOffset( $offset ) { if ( !is_string( $offset ) || !ctype_digit( $offset ) ) { throw new InvalidArgumentException( '$offset needs to be a string representing a positive integer' ); } + } + protected function getValueFromString( $valueString ) { + $valueSerialization = $this->getValueSerialization( $valueString ); + + try { + return $this->dvFactory->newFromArray( $valueSerialization ); + } + catch ( RuntimeException $ex ) { + throw new InvalidArgumentException( $ex->getMessage(), 0, $ex ); + } + } + + protected function getValueSerialization( $valueString ) { if ( !is_string( $valueString ) ) { throw new InvalidArgumentException( '$valueString needs to be a string serialization of a DataValue' ); } @@ -86,9 +111,12 @@ throw new InvalidArgumentException( 'The provided value needs to be a serialization of a DataValue' ); } + return $valueSerialization; + } + + protected function getPropertyIdFromString( $propertyIdString ) { try { $propertyId = $this->idParser->parse( $propertyIdString ); - $value = $this->dvFactory->newFromArray( $valueSerialization ); } catch ( RuntimeException $ex ) { throw new InvalidArgumentException( $ex->getMessage(), 0, $ex ); @@ -98,7 +126,7 @@ throw new InvalidArgumentException( 'The provided EntityId needs to be a PropertyId' ); } - return $this->findByPropertyValue( $propertyId, $value, $limit, $offset ); + return $propertyId; } /** -- To view, visit https://gerrit.wikimedia.org/r/83800 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7e692d82deb145d0f2f99bbbb8654f5b8413d581 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQuery Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Daniel Werner <daniel.wer...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits