1 | <?php |
||
10 | final class Course implements ModelInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $id; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $name; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | private $level; |
||
26 | |||
27 | const LEVEL_START = 1; |
||
28 | const LEVEL_MEDIUM = 2; |
||
29 | const LEVEL_ADVANCED = 3; |
||
30 | const LEVEL_EXPERT = 4; |
||
31 | |||
32 | const LEVEL = [ |
||
33 | self::LEVEL_START, |
||
34 | self::LEVEL_MEDIUM, |
||
35 | self::LEVEL_ADVANCED, |
||
36 | self::LEVEL_EXPERT, |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * @var float |
||
41 | */ |
||
42 | private $progress; |
||
43 | |||
44 | /** |
||
45 | * @var bool |
||
46 | */ |
||
47 | private $active; |
||
48 | |||
49 | private function __construct() |
||
52 | |||
53 | /** |
||
54 | * @param string|null $id |
||
55 | * |
||
56 | * @return self |
||
57 | */ |
||
58 | public static function create(string $id = null): self |
||
65 | |||
66 | /** |
||
67 | * @param array $data |
||
68 | * |
||
69 | * @return self|ModelInterface |
||
70 | */ |
||
71 | public static function fromPersistence(array $data): ModelInterface |
||
82 | |||
83 | /** |
||
84 | * @return array |
||
85 | */ |
||
86 | public function toPersistence(): array |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getId(): string |
||
104 | |||
105 | /** |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getName(): string |
||
112 | |||
113 | /** |
||
114 | * @param string $name |
||
115 | * |
||
116 | * @return self |
||
117 | */ |
||
118 | public function setName(string $name): self |
||
124 | |||
125 | /** |
||
126 | * @return int |
||
127 | */ |
||
128 | public function getLevel(): int |
||
132 | |||
133 | /** |
||
134 | * @param int $level |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | public function setLevel(int $level): self |
||
144 | |||
145 | /** |
||
146 | * @return float |
||
147 | */ |
||
148 | public function getProgress(): float |
||
152 | |||
153 | /** |
||
154 | * @param float $progress |
||
155 | * |
||
156 | * @return self |
||
157 | */ |
||
158 | public function setProgress(float $progress): self |
||
164 | |||
165 | /** |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function isActive(): bool |
||
172 | |||
173 | /** |
||
174 | * @param bool $active |
||
175 | * |
||
176 | * @return self |
||
177 | */ |
||
178 | public function setActive(bool $active): self |
||
184 | } |
||
185 |