Completed
Pull Request — master (#670)
by no
08:19 queued 04:50
created

EntityId   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 46
c 1
b 0
f 0
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
getEntityType() 0 1 ?
A getSerialization() 0 3 1
A __toString() 0 3 1
A equals() 0 8 3
1
<?php
2
3
namespace Wikibase\DataModel\Entity;
4
5
use Comparable;
6
use Serializable;
7
8
/**
9
 * @since 0.5
10
 * Constructor non-public since 1.0
11
 * Abstract since 2.0
12
 *
13
 * @license GPL-2.0+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
abstract class EntityId implements Comparable, Serializable {
17
18
	protected $serialization;
19
20
	/**
21
	 * @return string
22
	 */
23
	public abstract function getEntityType();
24
25
	/**
26
	 * @return string
27
	 */
28 31
	public function getSerialization() {
29 31
		return $this->serialization;
30
	}
31
32
	/**
33
	 * This is a human readable representation of the EntityId.
34
	 * This format is allowed to change and should therefore not
35
	 * be relied upon to be stable.
36
	 *
37
	 * @return string
38
	 */
39 5
	public function __toString() {
40 5
		return $this->serialization;
41
	}
42
43
	/**
44
	 * @see Comparable::equals
45
	 *
46
	 * @since 0.5
47
	 *
48
	 * @param mixed $target
49
	 *
50
	 * @return bool
51
	 */
52 5
	public function equals( $target ) {
53 5
		if ( $this === $target ) {
54 5
			return true;
55
		}
56
57
		return $target instanceof self
58 5
			&& $target->serialization === $this->serialization;
59
	}
60
61
}
62