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]>
Signed-off-by: Faraz Samapoor <[email protected]>
  • Loading branch information
fsamapoor committed Aug 15, 2023
1 parent 240e8ab commit 4d82b62
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 4d82b62

Please sign in to comment.