EndPointParametersTrait::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Parroauth2\Client\EndPoint;
4
5
/**
6
 * Implementation of the parameters for EndPointInterface
7
 *
8
 * @psalm-require-implements EndPointInterface
9
 */
10
trait EndPointParametersTrait
11
{
12
    /**
13
     * @var array
14
     * @readonly
15
     */
16
    private $parameters = [];
17
18
19
    /**
20
     * {@inheritdoc}
21
     *
22
     * @psalm-mutation-free
23
     */
24 32
    public function get(string $parameter)
25
    {
26 32
        return $this->parameters[$parameter] ?? null;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @psalm-mutation-free
33
     */
34 78
    public function parameters(): array
35
    {
36 78
        return $this->parameters;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     *
42
     * @param mixed $value
43
     *
44
     * @return static
45
     *
46
     * @psalm-mutation-free
47
     */
48 66
    public function set(string $parameter, $value): self
49
    {
50 66
        $endpoint = clone $this;
51
52 66
        $endpoint->parameters[$parameter] = $value;
53
54 66
        return $endpoint;
55
    }
56
}
57