Created
August 20, 2021 08:55
-
-
Save acrossoffwest/d0ecfb32cf3b06d0925581263a29588b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('load_class_names_from_dir')) { | |
function load_class_names_from_dir(string $dir): array | |
{ | |
$files = scandir($dir); | |
if (!$files) { | |
return []; | |
} | |
return array_filter(array_map(function ($filename) use ($dir) { | |
$extension = '.php'; | |
if (in_array($filename, ['.', '..']) || !str_contains($filename, $extension)) { | |
return null; | |
} | |
return str_replace($extension, '', $filename); | |
}, $files)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment