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 — develop ( e9751c...18a90f )
by Baptiste
03:20 queued 11s
created

UnionType::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 6
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 13
rs 10
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable\Specification;
5
6
use Innmind\Immutable\{
7
    SpecificationInterface,
8
    Exception\InvalidArgumentException
9
};
10
11
final class UnionType implements SpecificationInterface
12
{
13
    private $types;
14
15
    public function __construct(
16
        SpecificationInterface $first,
17
        SpecificationInterface $second,
18
        SpecificationInterface ...$rest
19
    ) {
20
        \array_unshift($rest, $second);
21
        \array_unshift($rest, $first);
22
23
        $this->types = $rest;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function validate($value): void
30
    {
31
        foreach ($this->types as $type) {
32
            try {
33
                $type->validate($value);
34
35
                return;
36
            } catch (InvalidArgumentException $e) {
37
                // try next type
38
            }
39
        }
40
41
        throw new InvalidArgumentException;
42
    }
43
}
44