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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A validate() 0 13 3
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