Completed
Push — master ( f47056...b8c4ef )
by adam
8s
created

Redirect   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 73.32%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 47
ccs 11
cts 15
cp 0.7332
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 6 1
A jsonDeserialize() 0 6 1
A __construct() 0 4 1
A getFrom() 0 3 1
A getTo() 0 3 1
1
<?php
2
3
namespace Mediawiki\DataModel;
4
5
use JsonSerializable;
6
7
class Redirect implements JsonSerializable {
8
9
	private $from;
10
	private $to;
11
12 1
	public function __construct( Title $from, Title $to ) {
13 1
		$this->from = $from;
14 1
		$this->to = $to;
15 1
	}
16
17
	/**
18
	 * @return Title
19
	 */
20
	public function getFrom() {
21
		return $this->from;
22
	}
23
24
	/**
25
	 * @return Title
26
	 */
27
	public function getTo() {
28
		return $this->to;
29
	}
30
31
	/**
32
	 * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
33
	 */
34 1
	public function jsonSerialize() {
35
		return array(
36 1
			'from' => $this->from->jsonSerialize(),
37 1
			'to' => $this->to->jsonSerialize(),
38
		);
39
	}
40
41
	/**
42
	 * @param array $json
43
	 *
44
	 * @return self
45
	 */
46 1
	public static function jsonDeserialize( $json ) {
47 1
		return new self(
48 1
			Title::jsonDeserialize( $json['from'] ),
49 1
			Title::jsonDeserialize( $json['to'] )
50
		);
51
	}
52
53
}
54