getRedirectTargetId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 0
cp 0
crap 2
rs 10
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