32 lines
732 B
PHP
32 lines
732 B
PHP
<?php
|
|
|
|
namespace Libs;
|
|
|
|
/**
|
|
* Loader - DuckBrain
|
|
*
|
|
* Simple library to bulk load multiple php files inside a folder.
|
|
*
|
|
* @author KJ
|
|
* @website https://kj2.me
|
|
* @license MIT
|
|
*/
|
|
class Loader
|
|
{
|
|
/**
|
|
* Loads all PHP files from a specified directory.
|
|
* If the directory does not exist or is not a directory, no files will be loaded.
|
|
*
|
|
* @param string $directoryPath The path to the directory containing the PHP files to load.
|
|
* @return void
|
|
*/
|
|
public static function load(string $directoryPath): void
|
|
{
|
|
if (is_dir($directoryPath)) {
|
|
foreach (glob(rtrim($directoryPath, '/') . '/*.php') as $file) {
|
|
require_once($file);
|
|
}
|
|
}
|
|
}
|
|
}
|