Completed
Pull Request — master (#1)
by Luc
04:53 queued 02:14
created

Question   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 169
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 169
rs 10
c 0
b 0
f 0
wmc 13

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getYear() 0 3 1
A getAnswers() 0 3 1
A getFeedback() 0 3 1
A getLanguage() 0 3 1
A getCategory() 0 3 1
A __construct() 0 18 1
A isArchived() 0 3 1
A getArchivedOn() 0 3 1
A getId() 0 3 1
A getPictureUri() 0 3 1
A getQuestionText() 0 3 1
A archiveOn() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Question\Models;
4
5
use League\Uri\Interfaces\Uri;
6
use Ramsey\Uuid\UuidInterface;
7
use VSV\GVQ_API\Question\ValueObjects\Language;
8
use VSV\GVQ_API\Question\ValueObjects\NotEmptyString;
9
use VSV\GVQ_API\Question\ValueObjects\Year;
10
11
class Question
12
{
13
    /**
14
     * @var UuidInterface
15
     */
16
    private $id;
17
18
    /**
19
     * @var Language
20
     */
21
    private $language;
22
23
    /**
24
     * @var Year
25
     */
26
    private $year;
27
28
    /**
29
     * @var Category
30
     */
31
    private $category;
32
33
    /**
34
     * @var NotEmptyString
35
     */
36
    private $questionText;
37
38
    /**
39
     * @var Uri
40
     */
41
    private $pictureUri;
42
43
    /**
44
     * @var Answers
45
     */
46
    private $answers;
47
48
    /**
49
     * @var NotEmptyString
50
     */
51
    private $feedback;
52
53
    /**
54
     * @var \DateTimeImmutable
55
     */
56
    private $archivedOn;
57
58
    /**
59
     * @param UuidInterface $id
60
     * @param Language $language
61
     * @param Year $year
62
     * @param Category $category
63
     * @param NotEmptyString $questionText
64
     * @param Uri $pictureUri
65
     * @param Answers $answers
66
     * @param NotEmptyString $feedback
67
     */
68
    public function __construct(
69
        UuidInterface $id,
70
        Language $language,
71
        Year $year,
72
        Category $category,
73
        NotEmptyString $questionText,
74
        Uri $pictureUri,
75
        Answers $answers,
76
        NotEmptyString $feedback
77
    ) {
78
        $this->id = $id;
79
        $this->language = $language;
80
        $this->year = $year;
81
        $this->category = $category;
82
        $this->questionText = $questionText;
83
        $this->pictureUri = $pictureUri;
84
        $this->answers = $answers;
85
        $this->feedback = $feedback;
86
    }
87
88
    /**
89
     * @return UuidInterface
90
     */
91
    public function getId(): UuidInterface
92
    {
93
        return $this->id;
94
    }
95
96
    /**
97
     * @return Language
98
     */
99
    public function getLanguage(): Language
100
    {
101
        return $this->language;
102
    }
103
104
    /**
105
     * @return Year
106
     */
107
    public function getYear(): Year
108
    {
109
        return $this->year;
110
    }
111
112
    /**
113
     * @return Category
114
     */
115
    public function getCategory(): Category
116
    {
117
        return $this->category;
118
    }
119
120
    /**
121
     * @return NotEmptyString
122
     */
123
    public function getQuestionText(): NotEmptyString
124
    {
125
        return $this->questionText;
126
    }
127
128
    /**
129
     * @return Uri
130
     */
131
    public function getPictureUri(): Uri
132
    {
133
        return $this->pictureUri;
134
    }
135
136
    /**
137
     * @return Answers
138
     */
139
    public function getAnswers(): Answers
140
    {
141
        return $this->answers;
142
    }
143
144
    /**
145
     * @return NotEmptyString
146
     */
147
    public function getFeedback(): NotEmptyString
148
    {
149
        return $this->feedback;
150
    }
151
152
    /**
153
     * @param \DateTimeImmutable $archiveOn
154
     */
155
    public function archiveOn(\DateTimeImmutable $archiveOn): void
156
    {
157
        if ($this->archivedOn !== null) {
158
            throw new \DomainException(
159
                'The question with id: "'.$this->getId()->toString().'" was already archived.'
160
            );
161
        }
162
163
        $this->archivedOn = $archiveOn;
164
    }
165
166
    /**
167
     * @return bool
168
     */
169
    public function isArchived(): bool
170
    {
171
        return $this->archivedOn !== null;
172
    }
173
174
    /**
175
     * @return \DateTimeImmutable
176
     */
177
    public function getArchivedOn(): ?\DateTimeImmutable
178
    {
179
        return $this->archivedOn;
180
    }
181
}
182