This repository was archived by the owner on Dec 26, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -10,34 +10,42 @@ Enumerated type for PHP by [Petr Knap].
10
10
11
11
### Usage of php-enum
12
12
13
+ #### Enum declaration
13
14
``` php
14
15
/**
16
+ * @method static DayOfWeekEnum SUNDAY()
15
17
* @method static DayOfWeekEnum MONDAY()
16
18
* @method static DayOfWeekEnum TUESDAY()
17
19
* @method static DayOfWeekEnum WEDNESDAY()
18
20
* @method static DayOfWeekEnum THURSDAY()
19
21
* @method static DayOfWeekEnum FRIDAY()
20
22
* @method static DayOfWeekEnum SATURDAY()
21
- * @method static DayOfWeekEnum SUNDAY()
22
23
*/
23
24
class DayOfWeekEnum extends \PetrKnap\Php\Enum\AbstractEnum
24
25
{
25
26
protected function __construct($constantName)
26
27
{
27
28
self::setConstants([
28
- "MONDAY " => 0,
29
- "TUESDAY " => 1,
30
- "WEDNESDAY " => 2,
31
- "THURSDAY " => 3,
32
- "FRIDAY " => 4,
33
- "SATURDAY " => 5,
34
- "SUNDAY " => 6
29
+ "SUNDAY " => 0,
30
+ "MONDAY " => 1,
31
+ "TUESDAY " => 2,
32
+ "WEDNESDAY " => 3,
33
+ "THURSDAY " => 4,
34
+ "FRIDAY " => 5,
35
+ "SATURDAY " => 6
35
36
]);
36
37
parent::__construct($constantName);
37
38
}
38
39
}
39
40
```
40
41
42
+ #### Enum usage
43
+ ``` php
44
+ if (date('w') == DayOfWeekEnum::FRIDAY()->getValue()) {
45
+ echo "Finally It's Friday!"
46
+ }
47
+ ```
48
+
41
49
42
50
## How to install
43
51
You can’t perform that action at this time.
0 commit comments