Skip to content

Commit

Permalink
Refactors tests/app.php to improve readaibility.
Browse files Browse the repository at this point in the history
Improves the readability of the "loadDirectory" function by extending guard clauses and early returns and reducing the code indentation.

Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
  • Loading branch information
fsamapoor committed Jun 27, 2023
1 parent 266436b commit 5ffc5ac
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tests/apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ function loadDirectory($path) {
if (strpos($path, 'integration')) {
return;
}

if (strpos($path, 'Integration')) {
return;
}
if ($dh = opendir($path)) {
while ($name = readdir($dh)) {
if ($name[0] !== '.') {
$file = $path . '/' . $name;
if (is_dir($file)) {
loadDirectory($file);
} elseif (substr($name, -4, 4) === '.php') {
require_once $file;
}
}

if (! $dh = opendir($path)) {
return;
}

while ($name = readdir($dh)) {
if ($name[0] === '.') {
continue;
}

$file = $path . '/' . $name;
if (is_dir($file)) {
loadDirectory($file);
} elseif (substr($name, -4, 4) === '.php') {
require_once $file;
}
}
}
Expand Down

0 comments on commit 5ffc5ac

Please sign in to comment.