Completed
Pull Request — master (#10)
by Tomáš
02:47
created

DefaultDataMap::process()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 4
nc 3
nop 1
crap 20
1
<?php
2
3
/*
4
 * This file is a part of Sculpin.
5
 *
6
 * (c) Dragonfly Development Inc.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Symplify\PHP7_Sculpin\Source\Map;
13
14
use Symplify\PHP7_Sculpin\Source\SourceInterface;
15
16
final class DefaultDataMap implements MapInterface
17
{
18
    private $defaults;
19
20
    public function __construct(array $defaults = [])
21
    {
22
        $this->defaults = $defaults;
23
    }
24
25
    public function process(SourceInterface $source)
26
    {
27
        foreach ($this->defaults as $name => $value) {
28
            if (!$source->data()->get($name) && $value) {
29
                $source->data()->set($name, $value);
30
            }
31
        }
32
    }
33
}
34