Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit b8222c3

Browse files
author
Petr Knap
committed
Update README.md
2 parents 284ea12 + 8c26b4f commit b8222c3

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ Enumerated type for PHP by [Petr Knap].
2323
*/
2424
class DayOfWeekEnum extends \PetrKnap\Php\Enum\AbstractEnum
2525
{
26-
protected function __construct($constantName)
26+
protected function __construct($memberName)
2727
{
28-
self::setConstants([
28+
self::setMembers([
2929
"SUNDAY" => 0,
3030
"MONDAY" => 1,
3131
"TUESDAY" => 2,
@@ -34,12 +34,39 @@ class DayOfWeekEnum extends \PetrKnap\Php\Enum\AbstractEnum
3434
"FRIDAY" => 5,
3535
"SATURDAY" => 6
3636
]);
37-
parent::__construct($constantName);
37+
parent::__construct($memberName);
3838
}
3939
}
4040
```
4141

4242
#### Enum usage
43+
```php
44+
if (DayOfWeekEnum::FRIDAY() == DayOfWeekEnum::FRIDAY()) {
45+
echo "This is OK.";
46+
}
47+
```
48+
49+
```php
50+
if (DayOfWeekEnum::FRIDAY() == DayOfWeekEnum::MONDAY()) {
51+
echo "We are going to Hell!";
52+
}
53+
```
54+
55+
```php
56+
switch($dayOfWeek)
57+
{
58+
case DayOfWeekEnum::FRIDAY():
59+
echo "Finally it is Friday!";
60+
break;
61+
case DayOfWeekEnum::SATURDAY():
62+
case DayOfWeekEnum::SUNDAY():
63+
echo "It is leasure time!";
64+
break;
65+
default:
66+
echo "Just another working day...";
67+
}
68+
```
69+
4370
```php
4471
if (date('w') == DayOfWeekEnum::FRIDAY()->getValue()) {
4572
echo "Finally it is Friday!";

0 commit comments

Comments
 (0)