class ExcludeIterator
@internal This class is not covered by the backward compatibility promise for phpunit/php-file-iterator
Hierarchy
- class \SebastianBergmann\FileIterator\ExcludeIterator extends \RecursiveFilterIterator
Expanded class hierarchy of ExcludeIterator
File
-
vendor/
phpunit/ php-file-iterator/ src/ ExcludeIterator.php, line 21
Namespace
SebastianBergmann\FileIteratorView source
final class ExcludeIterator extends RecursiveFilterIterator {
/**
* @psalm-var list<string>
*/
private array $exclude;
/**
* @psalm-param list<string> $exclude
*/
public function __construct(RecursiveDirectoryIterator $iterator, array $exclude) {
parent::__construct($iterator);
$this->exclude = $exclude;
}
public function accept() : bool {
$current = $this->current();
assert($current instanceof SplFileInfo);
$path = $current->getRealPath();
if ($path === false) {
return false;
}
foreach ($this->exclude as $exclude) {
if (str_starts_with($path, $exclude)) {
return false;
}
}
return true;
}
public function hasChildren() : bool {
return $this->getInnerIterator()
->hasChildren();
}
public function getChildren() : self {
return new self($this->getInnerIterator()
->getChildren(), $this->exclude);
}
public function getInnerIterator() : RecursiveDirectoryIterator {
$innerIterator = parent::getInnerIterator();
assert($innerIterator instanceof RecursiveDirectoryIterator);
return $innerIterator;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ExcludeIterator::$exclude | private | property | @psalm-var list<string> |
ExcludeIterator::accept | public | function | |
ExcludeIterator::getChildren | public | function | |
ExcludeIterator::getInnerIterator | public | function | |
ExcludeIterator::hasChildren | public | function | |
ExcludeIterator::__construct | public | function | @psalm-param list<string> $exclude |