Completed
Push — main ( 1f6f71...689fbc )
by
unknown
04:30
created

Redirect::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Addwiki\Mediawiki\DataModel;
4
5
use JsonSerializable;
6
7
class Redirect implements JsonSerializable {
8
9
	private $from;
10
	private $to;
11
12
	public function __construct( Title $from, Title $to ) {
13
		$this->from = $from;
14
		$this->to = $to;
15
	}
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
	public function jsonSerialize() {
35
		return [
36
		'from' => $this->from->jsonSerialize(),
37
		'to' => $this->to->jsonSerialize(),
38
		];
39
	}
40
41
	/**
42
	 * @param array $json
43
	 *
44
	 * @return self
45
	 */
46
	public static function jsonDeserialize( $json ) {
47
		return new self(
48
		Title::jsonDeserialize( $json['from'] ),
49
		Title::jsonDeserialize( $json['to'] )
50
		);
51
	}
52
53
}
54