Completed
Pull Request — master (#7)
by adam
05:15
created

EditInfo::getMaxlag()   A

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 InvalidArgumentException;
6
7
/**
8
 * Represents flags that can be used when edits are made
9
 * @author Addshore
10
 */
11
class EditInfo {
12
13
	//minor flags
14
	const MINOR = true;
15
	const NOTMINOR = false;
16
	//bot flags
17
	const BOT = true;
18
	const NOTBOT = false;
19
	//maxlag flags
20
	const OFFLAG = null;
21
22
	/**
23
	 * @var EditInfo::MINOR|self::NOTMINOR
24
	 */
25
	protected $minor = false;
26
27
	/**
28
	 * @var EditInfo::BOT|self::NOTBOT
29
	 */
30
	protected $bot = false;
31
	
32
	/**
33
	 * @var integer
34
	 */
35
	protected $maxlag = null;
36
37
	/**
38
	 * @var string
39
	 */
40
	protected $summary = null;
41
42
	/**
43
	 * @param string $summary
44
	 * @param bool $minor
45
	 * @param bool $bot
46
	 * @param int $maxlag
47
	 *
48
	 * @throws InvalidArgumentException
49
	 */
50 9
	public function __construct( $summary = '', $minor = self::NOTMINOR, $bot = self::NOTBOT, $maxlag = self::OFFLAG ) {
51 9
		if( !is_string( $summary ) ) {
52 2
			throw new InvalidArgumentException( '$summary must be a string' );
53
		}
54 7
		if( !is_bool( $minor ) ) {
55 1
			throw new InvalidArgumentException( '$minor must be a bool' );
56
		}
57 6
		if( !is_bool( $bot ) ) {
58 1
			throw new InvalidArgumentException( '$bot must be a bool' );
59
		}
60 5
		if( !is_int( $maxlag ) && !is_null( $maxlag ) ) {
61
			throw new InvalidArgumentException( '$maxlag must be an integer or null' );	
62
		}
63 5
		$this->summary = $summary;
64 5
		$this->bot = $bot;
65 5
		$this->minor = $minor;
66 5
		$this->maxlag = $maxlag;
67 5
	}
68
69
	/**
70
	 * @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...
71
	 */
72 5
	public function getBot() {
73 5
		return $this->bot;
74
	}
75
76
	/**
77
	 * @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...
78
	 */
79 5
	public function getMinor() {
80 5
		return $this->minor;
81
	}
82
	
83
	/**
84
	 * @return integer|null
85
	 */
86
	public function getMaxlag() {
87
		return $this->maxlag;
88
	}
89
90
	/**
91
	 * @return string
92
	 */
93 5
	public function getSummary() {
94 5
		return $this->summary;
95
	}
96
97
}
98