UnresolvedEntityRedirectException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 10
c 3
b 0
f 0
dl 0
loc 38
ccs 0
cts 9
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
A getRedirectTargetId() 0 2 1
1
<?php
2
3
namespace Wikibase\DataModel\Services\Lookup;
4
5
use Exception;
6
use Wikibase\DataModel\Entity\EntityId;
7
8
/**
9
 * Exception indicating that an attempt was made to access a redirected EntityId
10
 * without resolving the redirect first.
11
 *
12
 * @since 1.1
13
 *
14
 * @license GPL-2.0-or-later
15
 * @author Daniel Kinzler
16
 */
17
class UnresolvedEntityRedirectException extends EntityLookupException {
18
19
	/**
20
	 * @var EntityId
21
	 */
22
	private $redirectTargetId;
23
24
	/**
25
	 * @param EntityId $entityId
26
	 * @param EntityId $redirectTargetId The ID of the target Entity of the redirect
27
	 * @param string|null $message Added in 3.1
28
	 * @param Exception|null $previous Added in 3.1
29
	 */
30
	public function __construct(
31
		EntityId $entityId,
32
		EntityId $redirectTargetId,
33
		$message = null,
34
		?Exception $previous = null
35
	) {
36
		$defaultMessage = 'Unresolved redirect from ' . $entityId->getSerialization() . ' to '
37
			. $redirectTargetId->getSerialization();
38
39
		parent::__construct(
40
			$entityId,
41
			$message ?: $defaultMessage,
42
			$previous
43
		);
44
45
		$this->redirectTargetId = $redirectTargetId;
46
	}
47
48
	/**
49
	 * Returns the ID of the entity referenced by the redirect.
50
	 *
51
	 * @return EntityId
52
	 */
53
	public function getRedirectTargetId() {
54
		return $this->redirectTargetId;
55
	}
56
57
}
58