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

Error   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A getReason() 0 3 1
A getField() 0 3 1
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