Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c6dc59
commit a15b6a6
Showing
3 changed files
with
48 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Wikibase\DataModel\Entity; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* A trivial EntityIdParser that only parses the serializations of ItemIds. This is particularly | ||
* useful in cases where URIs are used to refer to concepts in an external Wikibase repository, | ||
* e.g. when referencing globes in coordinate values, or units in quantity values. | ||
* | ||
* @since 4.3 | ||
* | ||
* @licence GNU GPL v2+ | ||
* @author Thiemo Mättig | ||
*/ | ||
class ItemIdParser implements EntityIdParser { | ||
|
||
/** | ||
* @param string $idSerialization | ||
* | ||
* @throws EntityIdParsingException | ||
* @return ItemId | ||
*/ | ||
public function parse( $idSerialization ) { | ||
try { | ||
return new ItemId( $idSerialization ); | ||
} catch ( InvalidArgumentException $ex ) { | ||
throw new EntityIdParsingException( $ex->getMessage() ); | ||
} | ||
} | ||
|
||
} |