Completed
Push — develop ( 5bf394...6bbee1 )
by Tom
06:47
created

ModuleListVersionIterator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A current() 0 10 1
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
12
use ArrayIterator;
13
use IteratorIterator;
14
use Magento\Framework\Module\ModuleListInterface;
15
use Magento\Framework\Module\ResourceInterface as ModuleResourceInterface;
16
17
/**
18
 * Class ModuleListIterator
19
 *
20
 * @package N98\Magento\Api
21
 */
22
class ModuleListVersionIterator extends IteratorIterator
23
{
24
    /**
25
     * @var ModuleResourceInterface
26
     */
27
    private $resource;
28
29
    public function __construct(ModuleListInterface $moduleList, ModuleResourceInterface $resource)
30
    {
31
        parent::__construct(new ArrayIterator($moduleList->getAll()));
32
33
        $this->resource = $resource;
34
    }
35
36
    /**
37
     * @return ModuleVersion
38
     */
39
    public function current()
40
    {
41
        $current = parent::current();
42
43
        $module = new Module($current['name'], $current['setup_version']);
44
45
        $moduleVersion = new ModuleVersion($module, $this->resource);
46
47
        return $moduleVersion;
48
    }
49
}
50