Completed
Push — master ( 1f36be...d8b059 )
by Beñat
03:59
created

MenuItem   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 59
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A changeParent() 0 5 1
A id() 0 4 1
A link() 0 4 1
A parentId() 0 4 1
A createdOn() 0 4 1
A updatedOn() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel library.
5
 *
6
 * Copyright (c) 2016 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 MenuItem
18
{
19
    private $id;
20
    private $link;
21
    private $createdOn;
22
    private $updatedOn;
23
    private $parentId;
24
25
    /**
26
     * This is a hack to make more readable database schema.
27
     * This property is populated by reflection from MenuTranslation.
28
     */
29
    private $menuTranslation;
0 ignored issues
show
Unused Code introduced by
The property $menuTranslation is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
30
31
    public function __construct(MenuItemId $id, MenuItemLink $link, MenuItemId $parentId = null)
32
    {
33
        $this->id = $id;
34
        $this->link = $link;
35
        $this->parentId = $parentId;
36
        $this->createdOn = new \DateTimeImmutable();
37
        $this->updatedOn = new \DateTimeImmutable();
38
    }
39
40
    public function changeParent(MenuItemId $parentId = null)
41
    {
42
        $this->parentId = $parentId;
43
        $this->updatedOn = new \DateTimeImmutable();
44
    }
45
46
    public function id()
47
    {
48
        return $this->id;
49
    }
50
51
    public function link()
52
    {
53
        return $this->link;
54
    }
55
56
    public function parentId()
57
    {
58
        return $this->parentId;
59
    }
60
61
    public function createdOn()
62
    {
63
        return $this->createdOn;
64
    }
65
66
    public function updatedOn()
67
    {
68
        return $this->updatedOn;
69
    }
70
71
    public function __toString()
72
    {
73
        return (string) $this->id->id();
74
    }
75
}
76