Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| IndexIterator | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| getIndexer | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| valid | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| current | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2018-2021 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\tao\model\search\index; |
| 22 | |
| 23 | use oat\tao\model\search\index\DocumentBuilder\IndexDocumentBuilderInterface; |
| 24 | use Zend\ServiceManager\ServiceLocatorAwareInterface; |
| 25 | use Zend\ServiceManager\ServiceLocatorAwareTrait; |
| 26 | |
| 27 | class IndexIterator extends \IteratorIterator implements ServiceLocatorAwareInterface |
| 28 | { |
| 29 | use ServiceLocatorAwareTrait; |
| 30 | |
| 31 | /** @var IndexDocumentBuilderInterface */ |
| 32 | private $indexService = null; |
| 33 | |
| 34 | protected function getIndexer(): IndexDocumentBuilderInterface |
| 35 | { |
| 36 | if (is_null($this->indexService)) { |
| 37 | $this->indexService = $this->getServiceLocator()->getContainer()->get(IndexDocumentBuilderInterface::class); |
| 38 | } |
| 39 | |
| 40 | return $this->indexService; |
| 41 | } |
| 42 | |
| 43 | public function valid(): bool |
| 44 | { |
| 45 | return $this->getInnerIterator()->valid(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return mixed|IndexDocument |
| 50 | * @throws \common_Exception |
| 51 | * @throws \common_exception_InconsistentData |
| 52 | */ |
| 53 | public function current() |
| 54 | { |
| 55 | return $this->getIndexer()->createDocumentFromResource($this->getInnerIterator()->current()); |
| 56 | } |
| 57 | } |