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

EditInfo   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 0
dl 0
loc 102
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 6
A getBot() 0 3 1
A getMinor() 0 3 1
A getMaxlag() 0 3 1
A getSummary() 0 3 1
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
0 ignored issues
show
Documentation introduced by
The doc-type EditInfo::BOT|self::NOTBOT could not be parsed: Unknown type name "EditInfo::BOT" at position 0. (view supported doc-types)

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.

Loading history...
87
	 */
88
	public function getBot() {
89
		return $this->bot;
90
	}
91
92
	/**
93
	 * @return EditInfo::MINOR|self::NOTMINOR
0 ignored issues
show
Documentation introduced by
The doc-type EditInfo::MINOR|self::NOTMINOR could not be parsed: Unknown type name "EditInfo::MINOR" at position 0. (view supported doc-types)

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.

Loading history...
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