Completed
Push — develop ( ad187c...f818a7 )
by Jaap
09:04
created

AbstractReducer::convertItems()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2016 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Application\ReadModel\Mapper\Project;
14
15
use phpDocumentor\DomainModel\ReadModel\Mapper\Project\Reducer;
16
17
abstract class AbstractReducer implements Reducer
18
{
19
    public function convertItems($items, $interpreter, $context)
20
    {
21
        $convertedItems = [];
22
        foreach ($items as $item) {
23
            $convertedItems[$item->getName()] = $this->convertItem($item, $interpreter, $context);
24
        }
25
        return $convertedItems;
26
    }
27
28
    public function convertItem($item, $interpreter, $context, $state = null)
29
    {
30
        $command = new Interpret($item, $context);
31
        $newInterpreter = clone $interpreter;
32
        return $newInterpreter->interpret($command, $state);
33
    }
34
}
35