Reservation::isGivenAway()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Clearcode\EHLibrary\Model;
4
5
use Ramsey\Uuid\UuidInterface;
6
7
final class Reservation implements Aggregate
8
{
9
    /** @var UuidInterface */
10
    private $reservationId;
11
    /** @var UuidInterface */
12
    private $bookId;
13
    /** @var string */
14
    private $email;
15
    /** @var \DateTime */
16
    private $givenAwayAt;
17
18
    /**
19
     * @param UuidInterface $reservationId
20
     * @param UuidInterface $bookId
21
     * @param string        $email
22
     */
23
    public function __construct(UuidInterface $reservationId, UuidInterface $bookId, $email)
24
    {
25
        $this->reservationId = $reservationId;
26
        $this->bookId        = $bookId;
27
        $this->email         = $email;
28
    }
29
30
    /**
31
     * @param \DateTime $givenAwayAt
32
     */
33
    public function giveAway(\DateTime $givenAwayAt)
34
    {
35
        if ($this->isGivenAway()) {
36
            return;
37
        }
38
39
        $this->givenAwayAt = $givenAwayAt;
40
    }
41
42
    /**
43
     * @return bool
44
     */
45
    public function isGivenAway()
46
    {
47
        return $this->givenAwayAt instanceof \DateTime;
48
    }
49
50
    /**
51
     * @return UuidInterface
52
     */
53
    public function id()
54
    {
55
        return $this->reservationId;
56
    }
57
58
    /**
59
     * @return UuidInterface
60
     */
61
    public function bookId()
62
    {
63
        return $this->bookId;
64
    }
65
66
    /**
67
     * @return \DateTime
68
     */
69
    public function givenAwayAt()
70
    {
71
        return $this->givenAwayAt;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function email()
78
    {
79
        return $this->email;
80
    }
81
}
82