Completed
Push — detect-covers-fails ( bd35c8...c3f051 )
by no
16:27 queued 12:25
created

ItemIdParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4286
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Wikibase\DataModel\Entity;
4
5
use InvalidArgumentException;
6
7
/**
8
 * A trivial EntityIdParser that only parses the serializations of ItemIds. This is particularly
9
 * useful in cases where URIs are used to refer to concepts in an external Wikibase repository,
10
 * e.g. when referencing globes in coordinate values, or units in quantity values.
11
 *
12
 * @since 4.4
13
 *
14
 * @licence GNU GPL v2+
15
 * @author Thiemo Mättig
16
 */
17
class ItemIdParser implements EntityIdParser {
18
19
	/**
20
	 * @param string $idSerialization
21
	 *
22
	 * @throws EntityIdParsingException
23
	 * @return ItemId
24
	 */
25
	public function parse( $idSerialization ) {
26
		try {
27
			return new ItemId( $idSerialization );
28
		} catch ( InvalidArgumentException $ex ) {
29
			throw new EntityIdParsingException( $ex->getMessage() );
30
		}
31
	}
32
33
}
34