doc/lib: Add `NonEmptyFileIterator' for iterating over non-empty files

refs #4820
This commit is contained in:
Eric Lippmann 2014-07-28 18:58:46 +02:00
parent 71e81087b3
commit 4f8cbb99dd
1 changed files with 31 additions and 0 deletions

View 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;
}
}