Passed
Push — master ( e8a696...8de9f1 )
by Artem
12:01
created

Error::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 1
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <http://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Exception;
13
14
/**
15
 * An object for describing a single error that occurred during the processing of a request.
16
 */
17
class Error
18
{
19
    /**
20
     * Error constructor.
21
     */
22
    public function __construct(protected string $reason, protected ?string $field) {}
23
24
    /**
25
     * What happened to cause this error. In most cases, this can be fixed immediately by
26
     * changing the data you sent in the request, but in some cases you will be instructed to
27
     * open a Support Ticket or perform some other action before you can complete the request
28
     * successfully.
29
     */
30 9
    public function getReason(): string
31
    {
32 9
        return $this->reason;
33
    }
34
35
    /**
36
     * The field in the request that caused this error. This may be a path, separated by
37
     * periods in the case of nested fields. In some cases this may come back as "null" if the
38
     * error is not specific to any single element of the request.
39
     */
40 4
    public function getField(): ?string
41
    {
42 4
        return $this->field;
43
    }
44
}
45