mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-22 21:34:28 +02:00
doc/lib: Add `NonEmptyFileIterator' for iterating over non-empty files
refs #4820
This commit is contained in:
parent
71e81087b3
commit
4f8cbb99dd
31
modules/doc/library/Doc/NonEmptyFileIterator.php
Normal file
31
modules/doc/library/Doc/NonEmptyFileIterator.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}
|
||||||
|
|
||||||
|
namespace Icinga\Module\Doc;
|
||||||
|
|
||||||
|
use RecursiveFilterIterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursive iterator over non-empty files
|
||||||
|
*/
|
||||||
|
class NonEmptyFileIterator extends RecursiveFilterIterator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Accept non-empty files
|
||||||
|
*
|
||||||
|
* @return bool Whether the current element of the iterator is acceptable
|
||||||
|
* through this filter
|
||||||
|
*/
|
||||||
|
public function accept()
|
||||||
|
{
|
||||||
|
$current = $this->getInnerIterator()->current();
|
||||||
|
/* @var $current \SplFileInfo */
|
||||||
|
if (! $current->isFile()
|
||||||
|
|| $current->getSize() === 0
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user