PathAttributeResolverOptions::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Maba\Bundle\RestBundle\Entity;
5
6
use RuntimeException;
7
8
class PathAttributeResolverOptions
9
{
10
    /**
11
     * @var string|null
12
     */
13
    private $parameterName;
14
15
    /**
16
     * @var string|null
17
     */
18
    private $pathPartName;
19
20
    /**
21
     * @var string|null
22
     */
23
    private $pathAttributeResolverType;
24
25
    /**
26
     * @var bool
27
     */
28
    private $resolutionMandatory;
29
30 81
    public function __construct()
31
    {
32 81
        $this->resolutionMandatory = true;
33 81
    }
34
35 81
    public function setParameterName(string $parameterName): self
36
    {
37 81
        $this->parameterName = $parameterName;
38 81
        return $this;
39
    }
40
41 81
    public function setPathPartName(string $pathPartName): self
42
    {
43 81
        $this->pathPartName = $pathPartName;
44 81
        return $this;
45
    }
46
47 81
    public function setPathAttributeResolverType(string $pathAttributeResolverType): self
48
    {
49 81
        $this->pathAttributeResolverType = $pathAttributeResolverType;
50 81
        return $this;
51
    }
52
53 7
    public function getParameterName(): string
54
    {
55 7
        if ($this->parameterName === null) {
56
            throw new RuntimeException('parameterName was not set');
57
        }
58 7
        return $this->parameterName;
59
    }
60
61 10
    public function getPathPartName(): string
62
    {
63 10
        if ($this->pathPartName === null) {
64
            throw new RuntimeException('pathPartName was not set');
65
        }
66 10
        return $this->pathPartName;
67
    }
68
69 84
    public function getPathAttributeResolverType(): string
70
    {
71 84
        if ($this->pathAttributeResolverType === null) {
72
            throw new RuntimeException('pathAttributeResolverType was not set');
73
        }
74 84
        return $this->pathAttributeResolverType;
75
    }
76
77
    /**
78
     * @return bool
79
     */
80 5
    public function isResolutionMandatory(): bool
81
    {
82 5
        return $this->resolutionMandatory;
83
    }
84
85
    /**
86
     * @param bool $resolutionMandatory
87
     * @return $this
88
     */
89 81
    public function setResolutionMandatory(bool $resolutionMandatory): self
90
    {
91 81
        $this->resolutionMandatory = $resolutionMandatory;
92 81
        return $this;
93
    }
94
}
95