Completed
Pull Request — master (#5)
by Samuel
07:07 queued 03:31
created

Error::getCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SMartins\Exceptions\JsonApi;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use SMartins\Exceptions\Traits\NotNullArrayable;
7
use SMartins\Exceptions\Response\ErrorHandledInterface;
8
use SMartins\Exceptions\Response\ErrorHandledCollectionInterface;
9
10
class Error implements Arrayable, ErrorHandledInterface
11
{
12
    use NotNullArrayable;
13
14
    /**
15
     * A unique identifier for this particular occurrence of the problem.
16
     *
17
     * @var string
18
     */
19
    protected $id;
20
21
    /**
22
     * @var \SMartins\Exceptions\JsonApi\Links
23
     */
24
    protected $links;
25
26
    /**
27
     * The HTTP status code applicable to this problem, expressed as a string value.
28
     *
29
     * @var string
30
     */
31
    protected $status;
32
33
    /**
34
     * An application-specific error code, expressed as a string value.
35
     *
36
     * @var string
37
     */
38
    protected $code;
39
40
    /**
41
     * A short, human-readable summary of the problem that SHOULD NOT change from
42
     * occurrence to occurrence of the problem, except for purposes of localization.
43
     *
44
     * @var string
45
     */
46
    protected $title;
47
48
    /**
49
     * A human-readable explanation specific to this occurrence of the problem.
50
     * Like title, this field’s value can be localized.
51
     *
52
     * @var string
53
     */
54
    protected $detail;
55
56
    /**
57
     * An object containing references to the source of the error.
58
     *
59
     * @var \SMartins\Exceptions\JsonApi\Source
60
     */
61
    protected $source;
62
63
    /**
64
     * Get a unique identifier for this particular occurrence of the problem.
65
     *
66
     * @return string
67
     */
68
    public function getId()
69
    {
70
        return $this->id;
71
    }
72
73
    /**
74
     * Set a unique identifier for this particular occurrence of the problem.
75
     *
76
     * @param string $id
77
     *
78
     * @return self
79
     */
80
    public function setId(string $id): self
81
    {
82
        $this->id = $id;
83
84
        return $this;
85
    }
86
87
    /**
88
     * Get the value of links.
89
     *
90
     * @return \SMartins\Exceptions\JsonApi\Links
91
     */
92
    public function getLinks()
93
    {
94
        return $this->links;
95
    }
96
97
    /**
98
     * Set the value of links.
99
     *
100
     * @param \SMartins\Exceptions\JsonApi\Links  $links
101
     *
102
     * @return self
103
     */
104
    public function setLinks(Links $links): self
105
    {
106
        $this->links = $links;
107
108
        return $this;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function getStatus(): string
115
    {
116
        return $this->status;
117
    }
118
119
    /**
120
     * Set the HTTP status code applicable to this problem, expressed as a string value.
121
     *
122
     * @param string $status
123
     *
124
     * @return self
125
     */
126
    public function setStatus(string $status): self
127
    {
128
        $this->status = $status;
129
130
        return $this;
131
    }
132
133
    /**
134
     * Get an application-specific error code, expressed as a string value.
135
     *
136
     * @return string
137
     */
138
    public function getCode()
139
    {
140
        return $this->code;
141
    }
142
143
    /**
144
     * Set an application-specific error code, expressed as a string value.
145
     *
146
     * @param string $code
147
     *
148
     * @return self
149
     */
150
    public function setCode(string $code): self
151
    {
152
        $this->code = $code;
153
154
        return $this;
155
    }
156
157
    /**
158
     * Get occurrence to occurrence of the problem, except for purposes of localization.
159
     *
160
     * @return string
161
     */
162
    public function getTitle(): string
163
    {
164
        return $this->title;
165
    }
166
167
    /**
168
     * Set occurrence to occurrence of the problem, except for purposes of localization.
169
     *
170
     * @param string $title
171
     *
172
     * @return self
173
     */
174
    public function setTitle(string $title): self
175
    {
176
        $this->title = $title;
177
178
        return $this;
179
    }
180
181
    /**
182
     * Get like title, this field’s value can be localized.
183
     *
184
     * @return string
185
     */
186
    public function getDetail()
187
    {
188
        return $this->detail;
189
    }
190
191
    /**
192
     * Set like title, this field’s value can be localized.
193
     *
194
     * @param string $detail
195
     *
196
     * @return self
197
     */
198
    public function setDetail(string $detail): self
199
    {
200
        $this->detail = $detail;
201
202
        return $this;
203
    }
204
205
    /**
206
     * Get an object containing references to the source of the error.
207
     *
208
     * @return \SMartins\Exceptions\JsonApi\Source
209
     */
210
    public function getSource()
211
    {
212
        return $this->source;
213
    }
214
215
    /**
216
     * Set an object containing references to the source of the error.
217
     *
218
     * @param \SMartins\Exceptions\JsonApi\Source  $source
219
     *
220
     * @return self
221
     */
222
    public function setSource(Source $source): self
223
    {
224
        $this->source = $source;
225
226
        return $this;
227
    }
228
229
    /**
230
     * {@inheritdoc}
231
     */
232
    public function toCollection(): ErrorHandledCollectionInterface
233
    {
234
        return new ErrorCollection([$this]);
235
    }
236
}
237