Passed
Push — master ( eec14a...4028c5 )
by Alexander
02:26
created

MaxItemsTrait::getMaxSelectedItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
namespace Maknz\Slack;
3
4
use InvalidArgumentException;
5
6
trait MaxItemsTrait
7
{
8
    /**
9
     * Maximum number of selected items.
10
     *
11
     * @var int
12
     */
13
    protected $max_selected_items;
14
15
    /**
16
     * Get the maximum number of selected items.
17
     *
18
     * @return int
19
     */
20 6
    public function getMaxSelectedItems()
21
    {
22 6
        return $this->max_selected_items;
23
    }
24
25
    /**
26
     * Set the maximum number of selected items.
27
     *
28
     * @param int $maxSelectedItems
29
     *
30
     * @return $this
31
     *
32
     * @throws \InvalidArgumentException
33
     */
34 8
    public function setMaxSelectedItems($maxSelectedItems)
35
    {
36 8
        if (is_int($maxSelectedItems) && $maxSelectedItems >= 1) {
37 4
            $this->max_selected_items = $maxSelectedItems;
38
39 4
            return $this;
40
        }
41
42 4
        throw new InvalidArgumentException('The max selected items must be a positive integer');
43
    }
44
}
45