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.

MultipleCondition   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A evaluate() 0 16 4
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Middleware
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Middleware\Condition;
16
17
use Psr\Http\Message\RequestInterface;
18
use Psr\Http\Message\ResponseInterface;
19
use Phossa2\Shared\Base\ObjectAbstract;
20
use Phossa2\Middleware\Interfaces\ConditionInterface;
21
22
/**
23
 * MultipleCondition
24
 *
25
 * Combine multiple conditions into one
26
 *
27
 * @package Phossa2\Middleware
28
 * @author  Hong Zhang <[email protected]>
29
 * @see     ObjectAbstract
30
 * @see     ConditionInterface
31
 * @version 2.0.0
32
 * @since   2.0.0 added
33
 */
34
class MultipleCondition extends ObjectAbstract implements ConditionInterface
35
{
36
    /**
37
     * @var    array
38
     * @access protected
39
     */
40
    protected $conditions;
41
42
    /**
43
     * @param  array $conditions
44
     * @access public
45
     */
46
    public function __construct(array $conditions)
47
    {
48
        $this->conditions = $conditions;
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function evaluate(
55
        RequestInterface $request,
56
        ResponseInterface $response
57
    )/*# : bool */ {
58
        foreach ($this->conditions as $cond) {
59
            if (is_callable($cond)) {
60
                $res = $cond($request, $response);
61
            } else {
62
                $res = $cond->evaluate($request, $response);
63
            }
64
            if (!$res) {
65
                return false;
66
            }
67
        }
68
        return true;
69
    }
70
}
71