ParentNormalizerContext   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 3
cbo 0
dl 0
loc 60
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A withRoot() 0 8 1
A getRoot() 0 4 1
A withFormat() 0 8 1
A getFormat() 0 4 1
A withParent() 0 9 1
A getParent() 0 4 1
A getLevel() 0 4 1
1
<?php
2
namespace Thunder\Serializard\NormalizerContext;
3
4
final class ParentNormalizerContext implements NormalizerContextInterface
5
{
6
    private $root;
7
    private $format;
8
    private $parent;
9
    /** @var int */
10
    private $level = 0;
11
12 10
    public function __construct()
13
    {
14 10
    }
15
16 9
    public function withRoot($root)
17
    {
18 9
        $context = clone $this;
19
20 9
        $context->root = $root;
21
22 9
        return $context;
23
    }
24
25 1
    public function getRoot()
26
    {
27 1
        return $this->root;
28
    }
29
30 9
    public function withFormat($format)
31
    {
32 9
        $context = clone $this;
33
34 9
        $context->format = $format;
35
36 9
        return $context;
37
    }
38
39 1
    public function getFormat()
40
    {
41 1
        return $this->format;
42
    }
43
44 9
    public function withParent($parent)
45
    {
46 9
        $context = clone $this;
47
48 9
        $context->parent = $parent;
49 9
        $context->level = $this->level + 1;
50
51 9
        return $context;
52
    }
53
54 1
    public function getParent()
55
    {
56 1
        return $this->parent;
57
    }
58
59 1
    public function getLevel()
60
    {
61 1
        return $this->level;
62
    }
63
}
64