Skip to content

Commit 5827632

Browse files
committed
rm $isEnum callback
1 parent 7c9e452 commit 5827632

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/AttributeMiddleware.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace LaravelAnnotation;
44

5+
use BackedEnum;
56
use Illuminate\Routing\ControllerMiddlewareOptions;
67
use LaravelAnnotation\Attribute\ClassMiddleware;
78
use LaravelAnnotation\Attribute\Middleware;
@@ -31,25 +32,13 @@ public function getMiddlewaresByAttributes(): array
3132
{
3233
$middlewares = [];
3334

34-
$isEnum = function (mixed $obj): bool {
35-
if (gettype($obj) !== 'object') return false;
36-
37-
$props = get_object_vars($obj);
38-
return
39-
count($props) === 2 &&
40-
isset($props['name']) &&
41-
isset($props['value']) &&
42-
is_string($props['name']) &&
43-
(is_string($props['value']) || is_numeric($props['value']));
44-
};
45-
4635
/** @return string[] */
47-
$filterArguments = function (array $arguments) use ($isEnum): array {
36+
$filterArguments = function (array $arguments): array {
4837
$items = [];
4938

5039
foreach ($arguments as $argument) {
5140
if (is_string($argument) && $argument !== '') $items[] = $argument;
52-
if ($isEnum($argument) && $argument->value !== '') $items[] = (string) $argument->value;
41+
if ($argument instanceof BackedEnum && $argument->value !== '') $items[] = (string) $argument->value;
5342
}
5443

5544
return $items;

0 commit comments

Comments
 (0)