EndPointParametersTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 45
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A set() 0 7 1
A parameters() 0 3 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