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.
Completed
Push — master ( 28953e...2be45e )
by Marco
01:28
created

MapErrors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
A __construct() 0 6 1
A to() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marcosh\PhpValidationDSL\Combinator;
6
7
use Marcosh\PhpValidationDSL\Result\ValidationResult;
8
use Marcosh\PhpValidationDSL\Validation;
9
10
final class MapErrors implements Validation
11
{
12
    /**
13
     * @var Validation
14
     */
15
    private $validation;
16
17
    /**
18
     * @var callable
19
     */
20
    private $function;
21
22
    private function __construct(
23
        Validation $validation,
24
        callable $function
25
    ) {
26
        $this->validation = $validation;
27
        $this->function = $function;
28
    }
29
30
    public static function to(
31
        Validation $validation,
32
        callable $function
33
    ) {
34
        return new self($validation, $function);
35
    }
36
37
    public function validate($data, array $context = []): ValidationResult
38
    {
39
        return $this->validation->validate($data)->mapErrors($this->function);
40
    }
41
}
42