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.

AbstractElement::removeClass()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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
10
namespace ZfTable;
11
12
use ZfTable\AbstractCommon;
13
14
abstract class AbstractElement extends AbstractCommon
15
{
16
17
    /**
18
     * Array of attributes
19
     * @var array
20
     */
21
    protected $attributes = array();
22
23
    /**
24
     * Array of class
25
     * @var array
26
     */
27
    protected $class = array();
28
29
    /**
30
     * Collections of decorators
31
     * @var array
32
     */
33
    protected $decorators = array();
34
35
36
    /**
37
     * Array of vars class
38
     * @var array
39
     */
40
    protected $varClass = array();
41
42
    /**
43
     * Array of vars attr
44
     * @var array
45
     */
46
    protected $varAttr= array();
47
48
    /**
49
     * Add new class to element
50
     *
51
     * @param string $class
52
     * @return $this
53
     */
54
    public function addClass($class)
55
    {
56
        if (!in_array($class, $this->class)) {
57
            $this->class[] = $class;
58
        }
59
        return $this;
60
    }
61
62
    /**
63
     * Remove class from element
64
     *
65
     * @param string $class
66
     * @return $this
67
     */
68
    public function removeClass($class)
69
    {
70
        if (($key = array_search($class, $this->class)) !== false) {
71
            unset($this->class[$key]);
72
        }
73
        return $this;
74
    }
75
76
     /**
77
     * Add new var class to element
78
      *
79
     * @param string $class
80
     * @return $this
81
     */
82
    public function addVarClass($class)
83
    {
84
        if (!in_array($class, $this->varClass)) {
85
            $this->varClass[] = $class;
86
        }
87
        return $this;
88
    }
89
90
    /**
91
     * Add new var class to element
92
     *
93
     * @param $name
94
     * @param $value
95
     * @return $this
96
     */
97
    public function addVarAttr($name, $value)
98
    {
99
        if (!in_array($name, $this->varAttr)) {
100
            $this->varAttr[$name] = $value;
101
        }
102
        return $this;
103
    }
104
105
    /**
106
     * Add new attribute to table, header, column or rowset
107
     *
108
     * @param string $name
109
     * @param string $value
110
     * @return mixed
111
     */
112
    public function addAttr($name, $value)
113
    {
114
        if (!in_array($name, $this->attributes)) {
115
            $this->attributes[$name] = $value;
116
        }
117
        return $this;
118
    }
119
120
    /**
121
     * Get string class from array
122
     * @return string
123
     */
124
    public function getClassName()
125
    {
126
        $className = '';
127
128
        if (count($this->class)) {
129
            $className = implode(' ', array_values($this->class));
130
        }
131
132
        if (count($this->varClass)) {
133
            $className .= ' ';
134
            $className .= implode(' ', array_values($this->varClass));
135
        }
136
        return $className;
137
    }
138
139
    /**
140
     * Get attributes as a string
141
     *
142
     * @return null|string
143
     */
144
    public function getAttributes()
145
    {
146
        $ret = array();
147
148
        if (count($this->attributes)) {
149
            foreach ($this->attributes as $name => $value) {
150
                $ret[] = sprintf($name . '="%s"', $value);
151
            }
152
        }
153
154
        if (count($this->varAttr)) {
155
            foreach ($this->varAttr as $name => $value) {
156
                $ret[] = sprintf($name . '="%s"', $value);
157
            }
158
        }
159
160
        if (strlen($className = $this->getClassName())) {
161
            $ret[] = sprintf('class="%s"', $className);
162
        }
163
        return ' ' . implode(' ', $ret);
164
    }
165
166
     /**
167
     * Clearing var classes
168
     */
169
    public function clearVar()
170
    {
171
        $this->varClass = array();
172
        $this->varAttr = array();
173
    }
174
175
    /**
176
     * Get collestions of decoratos
177
     * @return array
178
     */
179
    public function getDecorators()
180
    {
181
        return $this->decorators;
182
    }
183
184
    /**
185
     *
186
     * @param $decorators
187
     * @return $this
188
     */
189
    public function setDecorators($decorators)
190
    {
191
        $this->decorators = $decorators;
192
        return $this;
193
    }
194
195
    /**
196
     *
197
     * @param $decorator
198
     */
199
    protected function attachDecorator($decorator)
200
    {
201
        $this->decorators[] = $decorator;
202
    }
203
}
204