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
Branch v2 (b7a21f)
by Oliver
06:19 queued 03:39
created

ConjunctionInterceptor::__construct()   A

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 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace TYPO3\PharStreamWrapper\Interceptor;
3
4
/*
5
 * This file is part of the TYPO3 project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under the terms
8
 * of the MIT License (MIT). For the full copyright and license information,
9
 * please read the LICENSE file that was distributed with this source code.
10
 *
11
 * The TYPO3 project - inspiring people to share!
12
 */
13
14
use TYPO3\PharStreamWrapper\Assertable;
15
use TYPO3\PharStreamWrapper\Exception;
16
17
class ConjunctionInterceptor implements Assertable
18
{
19
    /**
20
     * @var Assertable[]
21
     */
22
    private $assertions;
23
24
    public function __construct(array $assertions)
25
    {
26
        $this->assertAssertions($assertions);
27
        $this->assertions = $assertions;
28
    }
29
30
    /**
31
     * Executes assertions based on all contained assertions.
32
     *
33
     * @param string $path
34
     * @param string $command
35
     * @return bool
36
     * @throws Exception
37
     */
38
    public function assert($path, $command)
39
    {
40
        if ($this->invokeAssertions($path, $command)) {
41
            return true;
42
        }
43
        throw new Exception(
44
            sprintf(
45
                'Assertion failed in "%s"',
46
                $path
47
            ),
48
            1539625084
49
        );
50
    }
51
52
    /**
53
     * @param Assertable[] $assertions
54
     */
55
    private function assertAssertions(array $assertions)
56
    {
57
        foreach ($assertions as $assertion) {
58
            if (!$assertion instanceof Assertable) {
59
                throw new \InvalidArgumentException(
60
                    sprintf(
61
                        'Instance %s must implement Assertable',
62
                        get_class($assertion)
63
                    ),
64
                    1539624719
65
                );
66
            }
67
        }
68
    }
69
70
    /**
71
     * @param string $path
72
     * @param string $command
73
     * @return bool
74
     */
75
    private function invokeAssertions($path, $command)
76
    {
77
        try {
78
            foreach ($this->assertions as $assertion) {
79
                if (!$assertion->assert($path, $command)) {
80
                    return false;
81
                }
82
            }
83
        } catch (Exception $exception) {
84
            return false;
85
        }
86
        return true;
87
    }
88
}
89