| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 14 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 10 | 
| CRAP Score | 2 | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 14 | 5 | public function addClass()  | 
            |
| 15 |     { | 
            ||
| 16 | 5 | $classes = func_get_args();  | 
            |
| 17 | 5 |         $classes = array_map('trim', $classes); | 
            |
| 18 | 5 |         if (is_array($classes)) { | 
            |
| 19 | 5 |             $classes = implode(' ', $classes).' '.$this->getAttrib('class'); | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 20 | 5 |             $newClasses = explode(' ', $classes); | 
            |
| 21 | 5 | $newClasses = array_filter($newClasses);  | 
            |
| 22 | 5 | $newClasses = array_unique($newClasses);  | 
            |
| 23 | 5 |             $this->setAttrib('class', trim(implode(' ', $newClasses))); | 
            |
| 24 | }  | 
            ||
| 25 | |||
| 26 | 5 | return $this;  | 
            |
| 27 | }  | 
            ||
| 28 | |||
| 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.