Completed
Push — master ( 59d7ed...ae11c9 )
by Marcos
05:17
created

Joiner   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A join() 0 6 1
A append() 0 7 1
A filter() 0 6 1
A execute() 0 7 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 3
    public function filter($key)
41
    {
42 3
        $this->manipulator->filter($key);
43
44 3
        return $this;
45
    }
46
47 15
    public function execute()
48
    {
49 15
        $serializedBase = $this->serializer->serialize($this->base);
50 15
        $this->base     = null;
51
52 15
        return $this->manipulator->process($serializedBase);
53
    }
54
}
55