Redirect::getFrom()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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