PropertyLookupException::getPropertyId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 4
c 2
b 1
f 0
nc 2
nop 0
dl 0
loc 6
ccs 1
cts 1
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Wikibase\DataModel\Services\Lookup;
4
5
use Exception;
6
use LogicException;
7
use Wikibase\DataModel\Entity\PropertyId;
8
9
/**
10
 * @since 2.0
11
 *
12
 * @license GPL-2.0-or-later
13
 * @author Addshore
14
 */
15
class PropertyLookupException extends EntityLookupException {
16
17
	/**
18
	 * @param PropertyId $propertyId
19
	 * @param string|null $message
20
	 * @param Exception|null $previous
21 1
	 */
22 1
	public function __construct( PropertyId $propertyId, $message = null, ?Exception $previous = null ) {
23 1
		parent::__construct(
24 1
			$propertyId,
25
			$message ?: 'Property lookup failed for: ' . $propertyId,
26 1
			$previous
27 1
		);
28
	}
29
30
	/**
31
	 * @return PropertyId
32 1
	 */
33 1
	public function getPropertyId() {
34
		$propertyId = $this->getEntityId();
35
		if ( !( $propertyId instanceof PropertyId ) ) {
36
			throw new LogicException( 'expected $propertyId to be of type PropertyId' );
37
		}
38
		return $propertyId;
39
	}
40
41
}
42