doc/lib: Add `NonEmptyFileIterator' for iterating over non-empty files
refs #4820
This commit is contained in:
parent
71e81087b3
commit
4f8cbb99dd
|
@ -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…
Reference in New Issue