Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
esyede authored Oct 28, 2023
1 parent 7604890 commit 92cebc6
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
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)
```

0 comments on commit 92cebc6

Please sign in to comment.