Passed
Pull Request — master (#1554)
by
unknown
02:54
created

setRequireAllRequiredProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 0
cp 0
crap 2
rs 10
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
    /**
17
     * @var bool
18 1
     */
19
    private $requireAllRequiredProperties = false;
20 1
21
    public static function create(): self
22
    {
23 6
        return new self();
24
    }
25 6
26
    public function getDirection(): int
27
    {
28 80
        return GraphNavigatorInterface::DIRECTION_DESERIALIZATION;
29
    }
30 80
31 80
    public function getDepth(): int
32
    {
33 77
        return $this->depth;
34
    }
35 77
36
    public function increaseDepth(): void
37
    {
38
        $this->depth += 1;
39 77
    }
40 77
41
    public function decreaseDepth(): void
42
    {
43
        if ($this->depth <= 0) {
44
            throw new LogicException('Depth cannot be smaller than zero.');
45
        }
46
47
        $this->depth -= 1;
48
    }
49
50
    public function setRequireAllRequiredProperties(bool $require): self
51
    {
52
        $this->requireAllRequiredProperties = $require;
53
54
        return $this;
55
    }
56
57
    public function getRequireAllRequiredProperties(): bool
58
    {
59
        return $this->requireAllRequiredProperties;
60
    }
61
}
62