DeserializationContext   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 34
ccs 13
cts 14
cp 0.9286
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A increaseDepth() 0 3 1
A getDepth() 0 3 1
A getDirection() 0 3 1
A decreaseDepth() 0 7 2
A create() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JMS\Serializer;
6
7
use JMS\Serializer\Exception\LogicException;
8
9
class DeserializationContext extends Context
10
{
11
    /**
12
     * @var int
13 5
     */
14
    private $depth = 0;
15 5
16
    public static function create(): self
17
    {
18 1
        return new self();
19
    }
20 1
21
    public function getDirection(): int
22
    {
23 6
        return GraphNavigatorInterface::DIRECTION_DESERIALIZATION;
24
    }
25 6
26
    public function getDepth(): int
27
    {
28 80
        return $this->depth;
29
    }
30 80
31 80
    public function increaseDepth(): void
32
    {
33 77
        $this->depth += 1;
34
    }
35 77
36
    public function decreaseDepth(): void
37
    {
38
        if ($this->depth <= 0) {
39 77
            throw new LogicException('Depth cannot be smaller than zero.');
40 77
        }
41
42
        $this->depth -= 1;
43
    }
44
}
45