Skip to content

Commit bbd5d25

Browse files
Jim-Webfoxgithub-actions[bot]
authored andcommitted
Update CHANGELOG
1 parent 15321a2 commit bbd5d25

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
All notable changes to `laravel-backed-enums` will be documented in this file.
44

5+
## Add support for direct value comparisons - 2023-02-27
6+
7+
Right now if you want to use `->isA` or `->isAny` or the other comparison methods you must pass in an enum instance, I.e.
8+
9+
```php
10+
$user->role->isA(MyEnum::from('admin')); // true
11+
$user->role->isA('admin'); // false
12+
13+
$user->role->isA(MyEnum::from('not-a-value')); // exception
14+
$user->role->isA('not-a-value'); // false
15+
16+
$user->role->isAny([MyEnum::from('admin')]); // true
17+
$user->role->isAny(['admin']); // false
18+
19+
$user->role->isAny([MyEnum::from('not-a-value')]); // exception
20+
$user->role->isAny(['not-a-value']); // false
21+
22+
```
23+
This release makes it so each pair of methods will act the same whether given a string value or an enum instance.
24+
25+
```php
26+
$user->role->isA(MyEnum::from('admin')); // true
27+
$user->role->isA('admin'); // true
28+
29+
$user->role->isA(MyEnum::from('not-a-value')); // exception
30+
$user->role->isA('not-a-value'); // exception
31+
32+
$user->role->isAny([MyEnum::from('admin')]); // true
33+
$user->role->isAny(['admin']); // true
34+
35+
$user->role->isAny([MyEnum::from('not-a-value')]); // exception
36+
$user->role->isAny(['not-a-value']); // exception
37+
38+
```
39+
This also applies for isAn, isNotA, isNotAn, isNotAny
40+
541
## v1.2.1 - 2023-02-22
642

743
### What's Changed

0 commit comments

Comments
 (0)