NovaApiErrorList   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 33
ccs 0
cts 9
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrors() 0 3 1
A withError() 0 7 1
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