GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 971fda...722cc4 )
by Markus
01:03 queued 12s
created

withValidationErrors()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 14
nc 2
nop 1
dl 0
loc 24
ccs 15
cts 15
cp 1
crap 2
rs 9.7998
c 1
b 1
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Mschindler83\ArrayAccess;
5
6
use Opis\JsonSchema\ValidationError;
7
8
class ArrayAccessValidationFailed extends \RuntimeException
9
{
10
    private array $errors;
11
12
    private ArrayAccess $errorMapping;
13
14 2
    public static function withValidationErrors(ValidationError ...$errors): self
15
    {
16 2
        $messages = \array_map(
17
            function(ValidationError $error) {
18 2
                return \sprintf(
19 2
                    'Error: [%s], Data pointer: [%s]',
20 2
                    $error->keyword(),
21 2
                    \implode(', ', $error->dataPointer()),
22
                );
23 2
            },
24 2
            $errors
25
        );
26
27 2
        $instance = new self(
28 2
            \sprintf('Json schema validation failed: %s', \implode(', ', $messages))
29
        );
30
31 2
        $instance->errors = $errors;
32 2
        $instance->errorMapping = ArrayAccess::create([]);
33 2
        foreach ($errors as $error) {
34 2
            $instance->errorMapping = $instance->errorMapping->writeAtPath((string) $error->keyword(), ...$error->dataPointer());
35
        }
36
37 2
        return $instance;
38
    }
39
40 1
    public function errorMapping(): ArrayAccess
41
    {
42 1
        return $this->errorMapping;
43
    }
44
}