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

ItemIdParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 7 2
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