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.

Focus::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 Focus implements Validation
11
{
12
    /**
13
     * @var callable
14
     */
15
    private $focus;
16
17
    /**
18
     * @var Validation
19
     */
20
    private $validation;
21
22
    /**
23
     * Focus constructor.
24
     * @param callable $focus :: $data -> mixed
25
     * @param Validation $validation
26
     */
27
    private function __construct(callable $focus, Validation $validation)
28
    {
29
        $this->focus = $focus;
30
        $this->validation = $validation;
31
    }
32
33
    /**
34
     * @param callable $focus :: $data -> mixed
35
     * @param Validation $validation
36
     * @return self
37
     */
38
    public static function on(callable $focus, Validation $validation): self
39
    {
40
        return new self($focus, $validation);
41
    }
42
43
    /**
44
     * @template T
45
     * @psalm-param T $data
46
     * @param mixed $data
47
     * @param array $context
48
     * @return ValidationResult
49
     */
50
    public function validate($data, array $context = []): ValidationResult
51
    {
52
        return $this->validation->validate(($this->focus)($data), $context)
53
            ->map(
54
                /**
55
                 * @return T
56
                 */
57
                function () use ($data) {
58
                    return $data;
59
                }
60
            );
61
    }
62
}
63