Folder::files PHP Method

files() public method

Return a collection of all files within the directory
public files ( array $ignore = null, boolean $plain = false ) : mixed
$ignore array
$plain boolean
return mixed When $plain is true an array will be returned. Otherwise a Collection
    public function files($ignore = null, $plain = false)
    {
        $raw = $this->scan($ignore);
        if ($plain) {
            $content = array();
            foreach ($raw as $file) {
                if (is_file($this->root . DS . $file)) {
                    $content[] = $file;
                }
            }
        } else {
            $content = new Collection();
            foreach ($raw as $file) {
                if (is_file($this->root . DS . $file)) {
                    $content->append($file, new Media($this->root . DS . $file));
                }
            }
        }
        return $content;
    }

Usage Example

Example #1
0
function gconfig(string $value = NULL)
{
    global $gconfig;
    if (empty($gconfig)) {
        $configs = array_merge(Folder::files(EXTERNAL_CONFIG_DIR, 'php'), Folder::files(CONFIG_DIR, 'php'), Folder::files(INTERNAL_CONFIG_DIR, 'php'));
        $gconfig = [];
        foreach ($configs as $file) {
            $file = removeExtension($file);
            $gconfig = array_merge($gconfig, (array) Config::get($file));
        }
    }
    if ($value === NULL) {
        return $gconfig;
    }
    return $gconfig[$value] ?? false;
}
All Usage Examples Of Folder::files