From aff45470ba212d1f1386a52ac8e9844f6b9e5626 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Thu, 16 Feb 2023 10:58:17 +0330 Subject: [PATCH] Refactors tests/app.php to improve readaibility. Improves the readability of the "loadDirectory" function by extending guard clauses and early returns and reducing the code indentation. Signed-off-by: Faraz Samapoor --- tests/apps.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/apps.php b/tests/apps.php index 27bd428d949ef..f8bb86ff57c7b 100644 --- a/tests/apps.php +++ b/tests/apps.php @@ -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; } } }