PropertyLookupException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 9
c 2
b 1
f 0
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPropertyId() 0 6 2
A __construct() 0 5 2
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