Redirect   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 47
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFrom() 0 3 1
A getTo() 0 3 1
A jsonSerialize() 0 6 1
A jsonDeserialize() 0 6 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 [
36 1
		'from' => $this->from->jsonSerialize(),
37 1
		'to' => $this->to->jsonSerialize(),
38 1
		];
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 1
		);
51
	}
52
53
}
54