Completed
Push — develop ( 38ffc4...0b6176 )
by Tom
05:53
created

ModuleListVersionIterator::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/*
3
 * @author Tom Klingenberg <[email protected]>
4
 * @copyright Copyright (c) 2016 netz98 new media GmbH (http://www.netz98.de)
5
 *
6
 * @see PROJECT_LICENSE.txt
7
 */
8
9
namespace N98\Magento\Api;
10
11
use ArrayIterator;
12
use IteratorIterator;
13
use Magento\Framework\Module\ModuleListInterface;
14
use Magento\Framework\Module\ResourceInterface as ModuleResourceInterface;
15
16
/**
17
 * Class ModuleListIterator
18
 *
19
 * @package N98\Magento\Api
20
 */
21
class ModuleListVersionIterator extends IteratorIterator
22
{
23
    /**
24
     * @var ModuleResourceInterface
25
     */
26
    private $resource;
27
28
    public function __construct(ModuleListInterface $moduleList, ModuleResourceInterface $resource)
29
    {
30
        parent::__construct(new ArrayIterator($moduleList->getAll()));
31
32
        $this->resource = $resource;
33
    }
34
35
    /**
36
     * @return ModuleVersion
37
     */
38
    public function current()
39
    {
40
        $current = parent::current();
41
42
        $module = new Module($current['name'], $current['setup_version']);
43
44
        $moduleVersion = new ModuleVersion($module, $this->resource);
45
46
        return $moduleVersion;
47
    }
48
}
49