summaryrefslogtreecommitdiff
path: root/bin/wiki/vendor/addwiki/mediawiki-datamodel/src/Log.php
blob: d3e486376fb3133c88c7a43f841641ef7f6211b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php

namespace Mediawiki\DataModel;

use JsonSerializable;

/**
 * @since 0.5
 */
class Log implements JsonSerializable {

	/**
	 * @var int
	 */
	private $id;

	/**
	 * @var string
	 */
	private $type;

	/**
	 * @var string
	 */
	private $action;

	/**
	 * @var string
	 */
	private $timestamp;

	/**
	 * @var string
	 */
	private $user;

	/**
	 * @var string
	 */
	private $comment;

	/**
	 * @var PageIdentifier
	 */
	private $pageIdentifier;

	/**
	 * @var array
	 */
	private $details;

	/**
	 * @param int $id
	 * @param string $type
	 * @param string $action
	 * @param string $timestamp
	 * @param string $user
	 * @param PageIdentifier $pageIdentifier
	 * @param string $comment
	 * @param array $details
	 */
	public function __construct( $id, $type, $action, $timestamp, $user, $pageIdentifier, $comment, $details ) {
		$this->id = $id;
		$this->type = $type;
		$this->action = $action;
		$this->timestamp = $timestamp;
		$this->user = $user;
		$this->pageIdentifier = $pageIdentifier;
		$this->comment = $comment;
		$this->details = $details;
	}

	/**
	 * @since 0.5
	 * @return string
	 */
	public function getUser() {
		return $this->user;
	}

	/**
	 * @since 0.5
	 * @return string
	 */
	public function getAction() {
		return $this->action;
	}

	/**
	 * @since 0.5
	 * @return string
	 */
	public function getComment() {
		return $this->comment;
	}

	/**
	 * @since 0.5
	 * @return int
	 */
	public function getId() {
		return $this->id;
	}

	/**
	 * @since 0.6
	 * @return PageIdentifier
	 */
	public function getPageIdentifier() {
		return $this->pageIdentifier;
	}

	/**
	 * @since 0.5
	 * @return string
	 */
	public function getTimestamp() {
		return $this->timestamp;
	}

	/**
	 * @since 0.5
	 * @return string
	 */
	public function getType() {
		return $this->type;
	}

	/**
	 * @since 0.5
	 * @return array
	 */
	public function getDetails() {
		return $this->details;
	}

	/**
	 * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
	 */
	public function jsonSerialize() {
		return array(
			'id' => $this->id,
			'type' => $this->type,
			'action' => $this->action,
			'timestamp' => $this->timestamp,
			'user' => $this->user,
			'pageidentifier' => $this->pageIdentifier,
			'comment' => $this->comment,
			'details' => $this->details,
		);
	}

	/**
	 * @param array $json
	 *
	 * @return self
	 */
	public static function jsonDeserialize( $json ) {
		return new self(
			$json['id'],
			$json['type'],
			$json['action'],
			$json['timestamp'],
			$json['user'],
			PageIdentifier::jsonDeserialize( $json['pageidentifier'] ),
			$json['comment'],
			$json['details']
		);
	}

}