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.

AbstractDecorator   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 73
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addCondition() 0 9 2
A attachCondition() 0 4 1
A validConditions() 0 14 4
1
<?php
2
/**
3
 * ZfTable ( Module for Zend Framework 2)
4
 *
5
 * @copyright Copyright (c) 2013 Piotr Duda [email protected]
6
 * @license   MIT License
7
 */
8
9
namespace ZfTable\Decorator;
10
11
use ZfTable\AbstractCommon;
12
use ZfTable\Decorator\Condition\ConditionFactory;
13
14
abstract class AbstractDecorator extends AbstractCommon implements DecoratorInterface
15
{
16
17
    /**
18
     * Decorator is adding before cotext
19
     */
20
    const PRE_CONTEXT   = 'pre';
21
22
23
    /**
24
     * Decorator is adding after context
25
     */
26
    const POST_CONTEXT  = 'post';
27
28
29
    /**
30
     * Decorator reset context and return only new context
31
     */
32
    const RESET_CONTEXT = 'reset';
33
34
     /**
35
     * Collections of conditions objects
36
     * @var array
37
     */
38
    protected $conditions = array();
39
40
    /**
41
     * Add new condition to decorator
42
     *
43
     * @param string $name
44
     * @param array $options
45
     * @return $this|null
46
     */
47
    public function addCondition($name, $options)
48
    {
49
        if ($this instanceof DataAccessInterface) {
50
            $condition = ConditionFactory::factory($name, $options);
51
            $condition->setDecorator($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<ZfTable\Decorator\AbstractDecorator>, but the function expects a object<ZfTable\Decorator\DataAccessInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
52
            $this->attachCondition($condition);
53
            return $this;
54
        }
55
    }
56
57
    /**
58
     * Attach new condition
59
     *
60
     * @param Condition\AbstractCondition $condition
61
     */
62
    protected function attachCondition($condition)
63
    {
64
        $this->conditions[] = $condition;
65
    }
66
67
    /**
68
     * Check if all conditions are valid
69
     *
70
     * @return boolean
71
     */
72
    public function validConditions()
73
    {
74
        if (!count($this->conditions)) {
75
            return true;
76
        }
77
78
        foreach ($this->conditions as $condition) {
79
            if (!$condition->isValid()) {
80
                return false;
81
            }
82
        }
83
84
        return true;
85
    }
86
}
87