Post::title()   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
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Cubiche\Domain\Model\Tests\Fixtures;
11
12
use Cubiche\Domain\Model\AggregateRoot;
13
14
/**
15
 * Post class.
16
 *
17
 * @author Ivannis Suárez Jerez <[email protected]>
18
 */
19
class Post extends AggregateRoot
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $title;
25
26
    /**
27
     * @var string
28
     */
29
    protected $content;
30
31
    /**
32
     * @var bool
33
     */
34
    protected $published = false;
35
36
    /**
37
     * Post constructor.
38
     *
39
     * @param PostId $id
40
     * @param string $title
41
     * @param string $content
42
     */
43
    public function __construct(PostId $id, $title, $content)
44
    {
45
        parent::__construct($id);
46
47
        $this->title = $title;
48
        $this->content = $content;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function title()
55
    {
56
        return $this->title;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function content()
63
    {
64
        return $this->content;
65
    }
66
67
    /**
68
     * @return bool
69
     */
70
    public function published()
71
    {
72
        return $this->published;
73
    }
74
75
    /**
76
     * @param $newTitle
77
     */
78
    public function changeTitle($newTitle)
79
    {
80
        $this->title = $newTitle;
81
    }
82
83
    /**
84
     * Publish a post.
85
     */
86
    public function publish()
87
    {
88
        $this->published = true;
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function equals($other)
95
    {
96
        return parent::equals($other) &&
97
            $this->title() == $other->title() &&
98
            $this->content() == $other->content() &&
99
            $this->published() == $other->published()
100
        ;
101
    }
102
}
103