Joiner   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 49
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A join() 0 6 1
A append() 0 7 1
A execute() 0 7 1
A filter() 0 8 1
1
<?php
2
3
namespace Uvinum\Joiner;
4
5
use Uvinum\Joiner\Manipulator\Manipulator;
6
use Uvinum\Joiner\Serializer\Serializer;
7
8
final class Joiner
9
{
10
    /** @var Serializer */
11
    private $serializer;
12
13
    /** @var Manipulator */
14
    private $manipulator;
15
16
    private $base;
17
18 15
    public function __construct(Serializer $serializer, Manipulator $manipulator)
19
    {
20 15
        $this->serializer  = $serializer;
21 15
        $this->manipulator = $manipulator;
22 15
        $this->base        = null;
23 15
    }
24
25 15
    public function join($arg)
26
    {
27 15
        $this->base = $arg;
28
29 15
        return $this;
30
    }
31
32 12
    public function append($key, $arg)
33
    {
34 12
        $serializedArg = $this->serializer->serialize($arg);
35 12
        $this->manipulator->append($key, $serializedArg);
36
37 12
        return $this;
38
    }
39
40
    public function filter(... $key)
41
    {
42 3
        array_map(function ($key_to_remove) {
43 3
            $this->manipulator->filter($key_to_remove);
44 3
        }, $key);
45
46 3
        return $this;
47
    }
48
49 15
    public function execute()
50
    {
51 15
        $serializedBase = $this->serializer->serialize($this->base);
52 15
        $this->base     = null;
53
54 15
        return $this->manipulator->process($serializedBase);
55
    }
56
}
57