Completed
Push — develop ( 38ffc4...0b6176 )
by Tom
05:53
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
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