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

MenuItem::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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