-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,28 @@ | ||
# simple-enum | ||
Simple enum for PHP < 8.1 | ||
Simple enum for PHP < 8.1 >= 5.3.0 | ||
|
||
### Usage: | ||
|
||
```php | ||
abstract class DaysOfWeek extends Enums | ||
{ | ||
const SUNDAY = 0; | ||
const MONDAY = 1; | ||
const TUESDAY = 2; | ||
const WEDNESDAY = 3; | ||
const THURSDAY = 4; | ||
const FRIDAY = 5; | ||
const SATURDAY = 6; | ||
} | ||
|
||
var_dump(DaysOfWeek::isValidName('esyede')) . PHP_EOL; // bool(false) | ||
var_dump(DaysOfWeek::isValidName('MONDAY')) . PHP_EOL; // bool(true) | ||
var_dump(DaysOfWeek::isValidName('Monday')) . PHP_EOL; // bool(true) | ||
var_dump(DaysOfWeek::isValidName('Monday', $strict = true)) . PHP_EOL; // bool(false) | ||
var_dump(DaysOfWeek::isValidName(0)) . PHP_EOL; // bool(false) | ||
|
||
var_dump(DaysOfWeek::isValidValue(0)) . PHP_EOL; // bool(true) | ||
var_dump(DaysOfWeek::isValidValue(5)) . PHP_EOL; // bool(true) | ||
var_dump(DaysOfWeek::isValidValue(7)) . PHP_EOL; // bool(false) | ||
var_dump(DaysOfWeek::isValidValue('FRIDAY')) . PHP_EOL; // bool(false) | ||
``` |