MenuItemOrder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 26
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 4
A order() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel package.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
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 LIN3S\CMSKernel\Domain\Model\Menu;
13
14
/**
15
 * @author Beñat Espiña <[email protected]>
16
 */
17
class MenuItemOrder
18
{
19
    private $order;
20
21
    public function __construct($order)
22
    {
23
        if (null === $order || '' === $order) {
24
            throw new EmptyMenuNameException();
25
        }
26
        $this->order = (int)$order;
27
28
        if ($this->order < 1) {
29
            throw new InvalidMenuItemOrderException();
30
        }
31
    }
32
33
    public function order()
34
    {
35
        return $this->order;
36
    }
37
38
    public function __toString()
39
    {
40
        return (string) $this->order();
41
    }
42
}
43