MenuItem::__toString()   A
last analyzed

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 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 MenuItem
18
{
19
    private $id;
20
    private $link;
21
    private $order;
22
    private $createdOn;
23
    private $updatedOn;
24
    private $parentId;
25
26
    /**
27
     * This is a hack to make more readable database schema.
28
     * This property is populated by reflection from MenuTranslation.
29
     */
30
    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...
31
32
    public function __construct(MenuItemId $id, MenuItemLink $link, MenuItemOrder $order, MenuItemId $parentId = null)
33
    {
34
        $this->id = $id;
35
        $this->link = $link;
36
        $this->order = $order;
37
        $this->parentId = $parentId;
38
        $this->createdOn = new \DateTimeImmutable();
39
        $this->updatedOn = new \DateTimeImmutable();
40
    }
41
42
    public function changeParent(MenuItemId $parentId = null)
43
    {
44
        $this->parentId = $parentId;
45
        $this->updatedOn = new \DateTimeImmutable();
46
    }
47
48
    public function id()
49
    {
50
        return $this->id;
51
    }
52
53
    public function link()
54
    {
55
        return $this->link;
56
    }
57
58
    public function order()
59
    {
60
        return $this->order;
61
    }
62
63
    public function parentId()
64
    {
65
        return $this->parentId;
66
    }
67
68
    public function createdOn()
69
    {
70
        return $this->createdOn;
71
    }
72
73
    public function updatedOn()
74
    {
75
        return $this->updatedOn;
76
    }
77
78
    public function __toString()
79
    {
80
        return (string) $this->id->id();
81
    }
82
}
83