Completed
Push — master ( ad9766...0403bf )
by WEBEWEB
01:26
created

IntegerPageTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPage() 0 3 1
A setPage() 0 7 3
1
<?php
2
3
/*
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2020 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Model\Attribute;
13
14
use InvalidArgumentException;
15
16
/**
17
 * Integer page trait.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Library\Core\Model\Attribute
21
 */
22
trait IntegerPageTrait {
23
24
    /**
25
     * Page.
26
     *
27
     * @var integer
28
     */
29
    protected $page;
30
31
    /**
32
     * Get the page.
33
     *
34
     * @return integer Returns the page.
35
     */
36
    public function getPage() {
37
        return $this->page;
38
    }
39
40
    /**
41
     * Set the page.
42
     *
43
     * @param integer $page The page.
44
     * @throws InvalidArgumentException Throws an invalid argument exception if the page is not between 1 and 65536.
45
     */
46
    public function setPage($page) {
47
        if ($page < 0 || 65536 < $page) {
48
            throw new InvalidArgumentException("The page must be between 1 and 65536");
49
        }
50
        $this->page = $page;
51
        return $this;
52
    }
53
}
54