| Conditions | 4 |
| Paths | 2 |
| Total Lines | 17 |
| Lines | 17 |
| Ratio | 100 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 1 | View Code Duplication | public function removeClass() |
| 33 | { |
||
| 34 | 1 | $removeClasses = func_get_args(); |
|
| 35 | 1 | $removeClasses = array_map('trim', $removeClasses); |
|
| 36 | 1 | if (is_array($removeClasses)) { |
|
| 37 | 1 | $classes = explode(' ', $this->getAttrib('class')); |
|
| 38 | 1 | foreach ($removeClasses as $class) { |
|
| 39 | 1 | $key = array_search($class, $classes); |
|
| 40 | 1 | if ($key !== false) { |
|
| 41 | 1 | unset($classes[$key]); |
|
| 42 | } |
||
| 43 | } |
||
| 44 | 1 | $this->setAttrib('class', implode(' ', $classes)); |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | return $this; |
|
| 48 | } |
||
| 49 | |||
| 59 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.