Completed
Push — feature/api ( 725c17...de88d6 )
by Laurent
01:40
created

CreateExpenseNoteCommand::getQuartile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 */
5
6
namespace flightlog\command;
7
8
use flightlog\exceptions\PeriodNotFinishedException;
9
10
/**
11
 * CreateExpenseNoteCommand class
12
 *
13
 * @author Laurent De Coninck <[email protected]>
14
 */
15
class CreateExpenseNoteCommand
16
{
17
18
    /**
19
     * @var int
20
     */
21
    private $year;
22
23
    /**
24
     * @var int
25
     */
26
    private $quartile;
27
28
    /**
29
     * @var int
30
     */
31
    private $userValidatorId;
32
33
    /**
34
     * @var string
35
     */
36
    private $privateNote;
37
38
    /**
39
     * @var string
40
     */
41
    private $publicNote;
42
43
    /**
44
     * @param int    $year
45
     * @param int    $quartile
46
     * @param int    $userValidatorId
47
     * @param string $privateNote
48
     * @param string $publicNote
49
     *
50
     * @throws PeriodNotFinishedException
51
     */
52
    public function __construct($year, $quartile, $userValidatorId, $privateNote, $publicNote)
53
    {
54
        $currentYear = date('Y');
55
        $currentQuarter = floor((date('n') - 1) / 3) + 1;
56
57
        if (!($year < $currentYear || ($year == $currentYear && $quartile < $currentQuarter))) {
58
            throw new PeriodNotFinishedException('');
59
        }
60
61
        $this->year = (int) $year;
62
        $this->quartile = (int) $quartile;
63
        $this->userValidatorId = (int) $userValidatorId;
64
        $this->privateNote = $privateNote;
65
        $this->publicNote = $publicNote;
66
    }
67
68
    /**
69
     * @return int
70
     */
71
    public function getYear()
72
    {
73
        return $this->year;
74
    }
75
76
    /**
77
     * @return int
78
     */
79
    public function getQuartile()
80
    {
81
        return $this->quartile;
82
    }
83
84
    /**
85
     * @return int
86
     */
87
    public function getUserValidatorId()
88
    {
89
        return $this->userValidatorId;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getPrivateNote()
96
    {
97
        return $this->privateNote;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getPublicNote()
104
    {
105
        return $this->publicNote;
106
    }
107
}