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 — develop ( 870d79...a1e45f )
by Baptiste
05:29
created

UnionType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A __invoke() 0 13 3
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable\ValidateArgument;
5
6
use Innmind\Immutable\{
7
    ValidateArgument,
8
    Type,
9
};
10
11
final class UnionType implements ValidateArgument
12
{
13
    private $types;
14
15 4
    public function __construct(
16
        ValidateArgument $first,
17
        ValidateArgument $second,
18
        ValidateArgument ...$rest
19
    ) {
20 4
        \array_unshift($rest, $second);
21 4
        \array_unshift($rest, $first);
22
23 4
        $this->types = $rest;
24 4
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 3
    public function __invoke($value, int $position): void
30
    {
31 3
        foreach ($this->types as $validate) {
32
            try {
33 3
                $validate($value, $position);
34
35 2
                return;
36 3
            } catch (\TypeError $e) {
37
                // try next type
38
            }
39
        }
40
41 1
        throw new \TypeError;
42
    }
43
}
44