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 <[email protected]>
  • Loading branch information
fsamapoor authored Feb 16, 2023
1 parent 5413855 commit aff4547
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 aff4547

Please sign in to comment.