NovaApiErrorList::withError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
3
namespace OrcaServices\NovaApi\Result;
4
5
/**
6
 * Class.
7
 */
8
final class NovaApiErrorList
9
{
10
    /**
11
     * @var NovaApiError[] errors
12
     */
13
    private $errors = [];
14
15
    /**
16
     * Add error.
17
     *
18
     * @param string|int $code The code
19
     * @param string $message The message
20
     * @param array|null $details The details
21
     *
22
     * @return NovaApiErrorList self
23
     */
24
    public function withError($code, string $message, array $details = null): NovaApiErrorList
25
    {
26
        $clone = clone $this;
27
28
        $clone->errors[] = new NovaApiError((string)$code, $message, $details);
29
30
        return $clone;
31
    }
32
33
    /**
34
     * Get errors.
35
     *
36
     * @return NovaApiError[] errors
37
     */
38
    public function getErrors(): array
39
    {
40
        return $this->errors;
41
    }
42
}
43