doc/lib: Remove DocSearchIterator::count()

refs #6630
This commit is contained in:
Eric Lippmann 2015-02-11 15:53:23 +01:00
parent 53af279ec2
commit fdec27d8a1
1 changed files with 11 additions and 19 deletions

View File

@ -3,8 +3,8 @@
namespace Icinga\Module\Doc\Search; namespace Icinga\Module\Doc\Search;
use Countable;
use RecursiveFilterIterator; use RecursiveFilterIterator;
use RecursiveIteratorIterator;
use Icinga\Data\Tree\TreeNodeIterator; use Icinga\Data\Tree\TreeNodeIterator;
/** /**
@ -14,7 +14,7 @@ use Icinga\Data\Tree\TreeNodeIterator;
* {@inheritdoc} * {@inheritdoc}
* } * }
*/ */
class DocSearchIterator extends RecursiveFilterIterator implements Countable class DocSearchIterator extends RecursiveFilterIterator
{ {
/** /**
* Search criteria * Search criteria
@ -24,7 +24,7 @@ class DocSearchIterator extends RecursiveFilterIterator implements Countable
protected $search; protected $search;
/** /**
* Search matches * Current search matches
* *
* @type DocSearchMatch[]|null * @type DocSearchMatch[]|null
*/ */
@ -92,20 +92,6 @@ class DocSearchIterator extends RecursiveFilterIterator implements Countable
return new static($this->getInnerIterator()->getChildren(), $this->search); return new static($this->getInnerIterator()->getChildren(), $this->search);
} }
/**
* {@inheritdoc}
*/
public function count()
{
$count = 0;
foreach ($this as $section) {
if ($this->getMatches() !== null) {
++$count;
}
}
return $count;
}
/** /**
* Whether the search did not yield any match * Whether the search did not yield any match
* *
@ -113,11 +99,17 @@ class DocSearchIterator extends RecursiveFilterIterator implements Countable
*/ */
public function isEmpty() public function isEmpty()
{ {
return $this->count() === 0; $iter = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iter as $section) {
if ($iter->getInnerIterator()->getMatches() !== null) {
return false;
}
}
return true;
} }
/** /**
* Get matches * Get current matches
* *
* @return DocSearchMatch[]|null * @return DocSearchMatch[]|null
*/ */