Completed
Push — master ( c66aa1...b705d2 )
by Dominik
04:19
created

Error::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\Error;
6
7
final class Error
8
{
9
    /**
10
     * @var string|null
11
     */
12
    private $scope;
13
14
    const SCOPE_METHOD = 'method';
15
    const SCOPE_RESOURCE = 'resource';
16
    const SCOPE_QUERY = 'query';
17
    const SCOPE_HEADER = 'header';
18
    const SCOPE_BODY = 'body';
19
    const SCOPE_SERVER = 'server';
20
21
    /**
22
     * Identifier.
23
     *
24
     * @var string
25
     */
26
    private $key;
27
28
    /**
29
     * Technical error description.
30
     *
31
     * @var string|null
32
     */
33
    private $detail;
34
35
    /**
36
     * Reference to the error causing form field, parameter, value, header, etc.
37
     *
38
     * @var string|null
39
     */
40
    private $reference;
41
42
    /**
43
     * Parameters which can be used by client in order to display a expressive error message.
44
     *
45
     * @var array|null
46
     */
47
    private $arguments;
48
49
    /**
50
     * @param string|null $scope
51
     * @param string      $key
52
     * @param string|null $detail
53
     * @param string|null $reference
54
     * @param array       $arguments
55
     */
56
    public function __construct(
57
        string $scope,
58
        string $key,
59
        string $detail = null,
60
        string $reference = null,
61
        array $arguments = []
62
    ) {
63
        $this->scope = $scope;
64
        $this->key = $key;
65
        $this->detail = $detail;
66
        $this->reference = $reference;
67
        $this->arguments = $arguments;
68
    }
69
70
    /**
71
     * @return null|string
72
     */
73
    public function getScope()
74
    {
75
        return $this->scope;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getKey(): string
82
    {
83
        return $this->key;
84
    }
85
86
    /**
87
     * @return string|null
88
     */
89
    public function getDetail()
90
    {
91
        return $this->detail;
92
    }
93
94
    /**
95
     * @return string|null
96
     */
97
    public function getReference()
98
    {
99
        return $this->reference;
100
    }
101
102
    /**
103
     * @return array|null
104
     */
105
    public function getArguments()
106
    {
107
        return $this->arguments;
108
    }
109
}
110