1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Addwiki\Mediawiki\DataModel; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Represents flags that can be used when edits are made |
9
|
|
|
* |
10
|
|
|
* @author Addshore |
11
|
|
|
*/ |
12
|
|
|
class EditInfo { |
13
|
|
|
|
14
|
|
|
// minor flags |
15
|
|
|
/** |
16
|
|
|
* @var bool |
17
|
|
|
*/ |
18
|
|
|
public const MINOR = true; |
19
|
|
|
/** |
20
|
|
|
* @var bool |
21
|
|
|
*/ |
22
|
|
|
public const NOTMINOR = false; |
23
|
|
|
// bot flags |
24
|
|
|
/** |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
public const BOT = true; |
28
|
|
|
/** |
29
|
|
|
* @var bool |
30
|
|
|
*/ |
31
|
|
|
public const NOTBOT = false; |
32
|
|
|
// maxlag flags |
33
|
|
|
/** |
34
|
|
|
* @var null |
35
|
|
|
*/ |
36
|
|
|
public const OFFLAG = null; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var EditInfo::MINOR|self::NOTMINOR |
40
|
|
|
*/ |
41
|
|
|
protected $minor = false; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var EditInfo::BOT|self::NOTBOT |
45
|
|
|
*/ |
46
|
|
|
protected $bot = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var int|null |
50
|
|
|
*/ |
51
|
|
|
protected $maxlag; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
protected $summary; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $summary |
60
|
|
|
* @param bool $minor |
61
|
|
|
* @param bool $bot |
62
|
|
|
* @param int|null $maxlag |
63
|
|
|
* |
64
|
|
|
* @throws InvalidArgumentException |
65
|
|
|
*/ |
66
|
|
|
public function __construct( $summary = '', $minor = self::NOTMINOR, $bot = self::NOTBOT, $maxlag = self::OFFLAG ) { |
67
|
|
|
if ( !is_string( $summary ) ) { |
68
|
|
|
throw new InvalidArgumentException( '$summary must be a string' ); |
69
|
|
|
} |
70
|
|
|
if ( !is_bool( $minor ) ) { |
71
|
|
|
throw new InvalidArgumentException( '$minor must be a bool' ); |
72
|
|
|
} |
73
|
|
|
if ( !is_bool( $bot ) ) { |
74
|
|
|
throw new InvalidArgumentException( '$bot must be a bool' ); |
75
|
|
|
} |
76
|
|
|
if ( !is_int( $maxlag ) && $maxlag !== null ) { |
77
|
|
|
throw new InvalidArgumentException( '$maxlag must be an integer or null' ); |
78
|
|
|
} |
79
|
|
|
$this->summary = $summary; |
80
|
|
|
$this->bot = $bot; |
81
|
|
|
$this->minor = $minor; |
82
|
|
|
$this->maxlag = $maxlag; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return EditInfo::BOT|self::NOTBOT |
|
|
|
|
87
|
|
|
*/ |
88
|
|
|
public function getBot() { |
89
|
|
|
return $this->bot; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return EditInfo::MINOR|self::NOTMINOR |
|
|
|
|
94
|
|
|
*/ |
95
|
|
|
public function getMinor() { |
96
|
|
|
return $this->minor; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return int|null |
101
|
|
|
*/ |
102
|
|
|
public function getMaxlag() { |
103
|
|
|
return $this->maxlag; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
|
|
public function getSummary() { |
110
|
|
|
return $this->summary; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.