1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace ProjetNormandie\PageBundle\ValueObject; |
||
6 | |||
7 | use Webmozart\Assert\Assert; |
||
8 | |||
9 | class PageStatus |
||
10 | { |
||
11 | public const string PUBLIC = 'PUBLIC'; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
12 | public const string PRIVATE = 'PRIVATE'; |
||
13 | |||
14 | public const array VALUES = [ |
||
15 | self::PUBLIC, |
||
16 | self::PRIVATE, |
||
17 | ]; |
||
18 | |||
19 | private string $value; |
||
20 | |||
21 | public function __construct(string $value) |
||
22 | { |
||
23 | self::inArray($value); |
||
24 | |||
25 | $this->value = $value; |
||
26 | } |
||
27 | |||
28 | public static function inArray(string $value): void |
||
29 | { |
||
30 | Assert::inArray($value, self::VALUES); |
||
31 | } |
||
32 | |||
33 | public function getValue(): string |
||
34 | { |
||
35 | return $this->value; |
||
36 | } |
||
37 | |||
38 | public function __toString(): string |
||
39 | { |
||
40 | return $this->value; |
||
41 | } |
||
42 | |||
43 | public function isPrivate(): bool |
||
44 | { |
||
45 | return self::PRIVATE === $this->value; |
||
46 | } |
||
47 | |||
48 | public function isPublic(): bool |
||
49 | { |
||
50 | return self::PUBLIC === $this->value; |
||
51 | } |
||
52 | |||
53 | public static function getStatusChoices(): array |
||
54 | { |
||
55 | return [ |
||
56 | self::PRIVATE => self::PRIVATE, |
||
57 | self::PUBLIC => self::PUBLIC, |
||
58 | ]; |
||
59 | } |
||
60 | } |
||
61 |