Completed
Pull Request — master (#2)
by Tomasz
02:10
created

ParentNormalizerContext::withFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 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
    public function __construct()
13
    {
14
    }
15
16
    public function withRoot($root)
17
    {
18
        $context = new self();
19
20
        $context->root = $root;
21
22
        return $context;
23
    }
24
25
    public function getRoot()
26
    {
27
        return $this->root;
28
    }
29
30
    public function withFormat($format)
31
    {
32
        $context = new self();
33
34
        $context->format = $format;
35
36
        return $context;
37
    }
38
39
    public function getFormat()
40
    {
41
        return $this->format;
42
    }
43
44
    public function withParent($parent)
45
    {
46
        $context = new self();
47
48
        $context->parent = $parent;
49
        $context->level = $this->level + 1;
50
51
        return $context;
52
    }
53
54
    public function getParent()
55
    {
56
        return $this->parent;
57
    }
58
59
    public function getLevel()
60
    {
61
        return $this->level;
62
    }
63
}
64