CappedCredit::setUser()   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
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace JhFlexiTime\Entity;
4
5
use JhFlexiTime\DateTime\DateTime;
6
use ZfcUser\Entity\UserInterface;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * Class CappedCredit
11
 * @package JhFlexiTime\Entity
12
 * @author Aydin Hassan <[email protected]>
13
 *
14
 * @ORM\Entity
15
 * @ORM\Table(name="capped_credit")
16
 */
17
class CappedCredit
18
{
19
    /**
20
     * @var UserInterface
21
     *
22
     * @ORM\Id
23
     * @ORM\ManyToOne(targetEntity="JhUser\Entity\User")
24
     */
25
    protected $user = null;
26
27
    /**
28
     * @var DateTime
29
     *
30
     * @ORM\Id
31
     * @ORM\Column(type="date", name="date", nullable=false)
32
     */
33
    protected $date;
34
35
    /**
36
     * @var float
37
     *
38
     * @ORM\Column(type="float", name="capped_credit", nullable=false)
39
     */
40
    protected $cappedCredit;
41
42
    /**
43
     * @return string
44
     */
45
    public function getId()
46
    {
47
        if (!$this->user) {
48
            throw new \RuntimeException("No User is set. Needed to generate ID");
49
        }
50
51
        return $this->date->format('U') . "-" . $this->user->getId();
52
    }
53
54
    /**
55
     *
56
     * @param UserInterface $user
57
     */
58
    public function setUser(UserInterface $user)
59
    {
60
        $this->user = $user;
61
    }
62
63
    /**
64
     * @return UserInterface
65
     */
66
    public function getUser()
67
    {
68
        return $this->user;
69
    }
70
71
    /**
72
     * @return DateTime
73
     */
74
    public function getDate()
75
    {
76
        return $this->date;
77
    }
78
79
    /**
80
     * @param DateTime $date
81
     */
82
    public function setDate(DateTime $date)
83
    {
84
        $this->date = $date;
85
    }
86
87
    /**
88
     * @return float
89
     */
90
    public function getCappedCredit()
91
    {
92
        return $this->cappedCredit;
93
    }
94
95
    /**
96
     * @param float $cappedCredit
97
     */
98
    public function setCappedCredit($cappedCredit)
99
    {
100
        $this->cappedCredit = $cappedCredit;
101
    }
102
}
103