Skip to content

Commit

Permalink
Add ItemIdParser
Browse files Browse the repository at this point in the history
  • Loading branch information
thiemowmde committed Sep 2, 2015
1 parent 6c6dc59 commit a15b6a6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
27 changes: 14 additions & 13 deletions RELEASE-NOTES.md
@@ -1,25 +1,26 @@
# Wikibase DataModel release notes

## Version 4.3 (dev)
## Version 4.3.0 (2015-09-02)

* Added `ItemIdParser`
* Added `isEmpty` to `EntityDocument`

## Version 4.2 (2015-08-26)
## Version 4.2.0 (2015-08-26)

* Added `EntityRedirect`
* Added `EntityIdParser` and `EntityIdParsingException`
* Added `BasicEntityIdParser`
* Added `DispatchingEntityIdParser`
* Removed no longer needed dependency on `diff/diff`

## Version 4.1 (2015-08-04)
## Version 4.1.0 (2015-08-04)

* Added `StatementList::filter`
* Added `StatementFilter` and `ReferencedStatementFilter`
* Added `LabelsProvider`, `DescriptionsProvider` and `AliasesProvider`
* Added `FingerprintHolder`

## Version 4.0 (2015-07-28)
## Version 4.0.0 (2015-07-28)

#### Breaking changes

Expand Down Expand Up @@ -205,7 +206,7 @@ Other breaking changes:
* Deprecated `Claim::RANK_` enum in favour of `Statement::RANK_` enum
* Deprecated `Claim::getRank`

## Version 1.1 (2014-09-29)
## Version 1.1.0 (2014-09-29)

#### Additions

Expand All @@ -221,7 +222,7 @@ Other breaking changes:
* The `Reference` constructor now accepts a `Snak` array
* Added `ReferenceList::addNewReference`

## Version 1.0 (2014-09-02)
## Version 1.0.0 (2014-09-02)

#### Breaking changes

Expand Down Expand Up @@ -309,7 +310,7 @@ Other breaking changes:

* Fixed error caused by redeclaration of getType in `Entity`, after it already got defined in `EntityDocument`

## Version 0.9 (2014-08-15)
## Version 0.9.0 (2014-08-15)

* Changed the signatures of `setLabel`, `setDescription` and `setAliasGroup` in `Fingerprint`
* Added `hasLabel`, `hasDescription` and `hasAliasGroup` to `Fingerprint`
Expand All @@ -325,7 +326,7 @@ Other breaking changes:

* Fixed fatal error when calling `Item::getSiteLinkList` on an `Item` right after constructing it

## Version 0.8 (2014-06-05)
## Version 0.8.0 (2014-06-05)

#### Breaking changes

Expand Down Expand Up @@ -450,7 +451,7 @@ No description will be shown as part of its entry on Special:Version.
* Removed DataValues Geo, DataValues Time and DataValues Number from the dependency list.
They where no longer needed.

## Version 0.7 (2014-03-07)
## Version 0.7.0 (2014-03-07)

#### Additions

Expand All @@ -473,7 +474,7 @@ They where no longer needed.
* Removed PropertySnak interface
* Removed Claims::getObjectType

## Version 0.6 (2013-12-23)
## Version 0.6.0 (2013-12-23)

#### Improvements

Expand All @@ -494,7 +495,7 @@ Item::getSiteLinks. The old names remains as deprecated aliases.
* Entity::getTerms was removed, as it returned objects of type Term, which is defined by a component
Wikibase DataModel does not depend upon.

## Version 0.5 (2013-12-11)
## Version 0.5.0 (2013-12-11)

Note that this list is incomplete. In particular, not all breaking changes are listed.

Expand All @@ -520,10 +521,10 @@ representing the identity of an entity.
* Constructing an EntityId (rather then one of its derivatives) is now deprecated.
* Wikibase\EntityId has been renamed to Wikibase\DataModel\Entity\EntityId. The old name is deprecated.

## Version 0.4 (2013-06-17)
## Version 0.4.0 (2013-06-17)

Initial release as Wikibase DataModel component.

## Version 0.1 (2012-11-01)
## Version 0.1.0 (2012-11-01)

Initial release as part of Wikibase.
2 changes: 1 addition & 1 deletion WikibaseDataModel.php
Expand Up @@ -12,7 +12,7 @@
return 1;
}

define( 'WIKIBASE_DATAMODEL_VERSION', '4.2.0' );
define( 'WIKIBASE_DATAMODEL_VERSION', '4.3.0' );

if ( defined( 'MEDIAWIKI' ) ) {
call_user_func( function() {
Expand Down
33 changes: 33 additions & 0 deletions src/Entity/ItemIdParser.php
@@ -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() );
}
}

}

0 comments on commit a15b6a6

Please sign in to comment.