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

AbstractReducer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertItems() 0 8 2
A convertItem() 0 6 1
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