Completed
Push — master ( 2da631...379b27 )
by
unknown
14s
created

ReferencedEntityIdLookupException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 50
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 24 2
1
<?php
2
3
namespace Wikibase\DataModel\Services\Lookup;
4
5
use Exception;
6
use RuntimeException;
7
use Wikibase\DataModel\Entity\EntityId;
8
use Wikibase\DataModel\Entity\PropertyId;
9
10
/**
11
 * @since 3.10
12
 *
13
 * @license GPL-2.0-or-later
14
 * @author Marius Hoch
15
 */
16
class ReferencedEntityIdLookupException extends RuntimeException {
17
18
	/**
19
	 * @var EntityId
20
	 */
21
	private $fromId;
22
23
	/**
24
	 * @var PropertyId
25
	 */
26
	private $propertyId;
27
28
	/**
29
	 * @var EntityId[]
30
	 */
31
	private $toIds;
32
33
	/**
34
	 * @param EntityId $fromId
35
	 * @param PropertyId $propertyId
36
	 * @param EntityId[] $toIds
37
	 * @param string|null $message
38
	 * @param Exception|null $previous
39
	 */
40
	public function __construct(
41
		EntityId $fromId,
42
		PropertyId $propertyId,
43
		array $toIds,
44
		$message = null,
45
		Exception $previous = null
46
	) {
47
		$this->fromId = $fromId;
48
		$this->propertyId = $propertyId;
49
		$this->toIds = $toIds;
50
51
		$targets = array_map(
52
			function ( EntityId $entityId ) {
53
				return $entityId->getSerialization();
54
			},
55
			$toIds
56
		);
57
		$targets = implode( ', ', $targets );
58
59
		$message = $message ?: 'Referenced entity id lookup failed. Tried to find a referenced entity out of ' .
60
			$targets . ' linked from ' . $fromId->getSerialization() . ' via ' . $propertyId->getSerialization();
61
62
		parent::__construct( $message, 0, $previous );
63
	}
64
65
}
66