FileExtensionFilter extends RecursiveFilterIterator
FileExtensionFilter class. This class extends RecursiveFilterIterator to filter files based on their extensions. It allows only files with specified extensions (default: 'md' and 'yml') to be accepted, while excluding certain directories (like '.git', '.cecil', '.cache', '_site', 'vendor', 'node_modules'). It can be used to traverse a directory structure and filter out unwanted files and directories.
Table of Contents
Properties
- $allowedExt : array<string|int, mixed>
- $excludedDir : array<string|int, mixed>
Methods
- __construct() : mixed
- accept() : bool
- Valid file with allowed extensions.
- getChildren() : RecursiveFilterIterator|null
- Get children with allowed extensions.
Properties
$allowedExt
protected
array<string|int, mixed>
$allowedExt
= ['md', 'yml']
$excludedDir
protected
array<string|int, mixed>
$excludedDir
= ['.git', '.cecil', '.cache', '_site', 'vendor', 'node_modules']
Methods
__construct()
public
__construct(RecursiveIterator $iterator[, string|array<string|int, mixed>|null $extensions = null ]) : mixed
Parameters
- $iterator : RecursiveIterator
- $extensions : string|array<string|int, mixed>|null = null
accept()
Valid file with allowed extensions.
public
accept() : bool
Return values
boolgetChildren()
Get children with allowed extensions.
public
getChildren() : RecursiveFilterIterator|null