NodeTranslation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A inLoop() 0 14 2
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Manipulator\Plugin;
12
13
use WebinoDraw\Dom\Element;
14
15
/**
16
 *
17
 */
18
class NodeTranslation extends AbstractPlugin implements InLoopPluginInterface
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $lastNodeTranslation = [];
24
25
    /**
26
     * @param PluginArgument $arg
27
     */
28
    public function inLoop(PluginArgument $arg)
29
    {
30
        $node = $arg->getNode();
31
        if (!$node instanceof Element) {
32
            return;
33
        }
34
35
        $translation = $arg->getTranslation();
36
        // unset the last node translation then merge current one
37
        $nodeTranslation = $this->createNodeTranslation($node, $arg->getSpec());
38
        $translation->unsetKeys(array_keys($this->lastNodeTranslation));
39
        $this->lastNodeTranslation = $nodeTranslation->getArrayCopy();
40
        $translation->merge($this->lastNodeTranslation);
41
    }
42
}
43