Errors::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php namespace HSkrasek\JsonSchema\Validator;
2
3
use League\JsonGuard\ValidationError;
4
5
class Errors
6
{
7
    /**
8
     * @var array|ValidationError[]
9
     */
10
    private $errors;
11
12
    public function __construct(array $errors)
13
    {
14
        $this->errors = $errors;
15
    }
16
17
    public function __toString(): string
18
    {
19
        return array_reduce($this->errors, function (string $carry, ValidationError $error) {
20
            return $carry .= $error->getMessage() . " ({$error->getDataPath()})" . PHP_EOL;
21
        }, '');
22
    }
23
}
24