ErrorWithValidation::withFields()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LibraryCatalog\Controller\V1\ValueObject;
6
7
class ErrorWithValidation extends Error
8
{
9
    /** @var array */
10
    public array $fields;
11
12
    /**
13
     * @param array $fields
14
     * @return ErrorWithValidation
15
     */
16 2
    public function withFields(array $fields): ErrorWithValidation
17
    {
18 2
        $this->fields = [];
19 2
        foreach ($fields as $name => $value) {
20 2
            $this->fields[$name] = _($value);
21
        }
22
23 2
        return $this;
24
    }
25
}
26