PathAttributeResolverOptions::setParameterName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\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 96
    public function __construct()
31
    {
32 96
        $this->resolutionMandatory = true;
33 96
    }
34
35 96
    public function setParameterName(string $parameterName): self
36
    {
37 96
        $this->parameterName = $parameterName;
38 96
        return $this;
39
    }
40
41 96
    public function setPathPartName(string $pathPartName): self
42
    {
43 96
        $this->pathPartName = $pathPartName;
44 96
        return $this;
45
    }
46
47 96
    public function setPathAttributeResolverType(string $pathAttributeResolverType): self
48
    {
49 96
        $this->pathAttributeResolverType = $pathAttributeResolverType;
50 96
        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 99
    public function getPathAttributeResolverType(): string
70
    {
71 99
        if ($this->pathAttributeResolverType === null) {
72
            throw new RuntimeException('pathAttributeResolverType was not set');
73
        }
74 99
        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 96
    public function setResolutionMandatory(bool $resolutionMandatory): self
90
    {
91 96
        $this->resolutionMandatory = $resolutionMandatory;
92 96
        return $this;
93
    }
94
}
95