ParentNormalizerContext::withRoot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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