Skip to content

Commit d0b9038

Browse files
dbuNyholm
authored andcommitted
simplify discovery code (#118)
avoid unnecessary elseif to reduce complexity. use foreach instead of for loop.
1 parent e975603 commit d0b9038

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/ClassDiscovery.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,17 @@ protected static function evaluateCondition($condition)
162162
if (is_string($condition)) {
163163
// Should be extended for functions, extensions???
164164
return self::safeClassExists($condition);
165-
} elseif (is_callable($condition)) {
166-
return $condition();
167-
} elseif (is_bool($condition)) {
165+
}
166+
if (is_callable($condition)) {
167+
return (bool) $condition();
168+
}
169+
if (is_bool($condition)) {
168170
return $condition;
169-
} elseif (is_array($condition)) {
170-
// Immediately stop execution if the condition is false
171-
for ($i = 0; $i < count($condition); ++$i) {
172-
if (false === static::evaluateCondition($condition[$i])) {
171+
}
172+
if (is_array($condition)) {
173+
foreach ($condition as $c) {
174+
if (false === static::evaluateCondition($c)) {
175+
// Immediately stop execution if the condition is false
173176
return false;
174177
}
175178
}

0 commit comments

Comments
 (0)