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

ParentNormalizerContext   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 60
c 0
b 0
f 0
wmc 8
lcom 1
cbo 0
rs 10

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
    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