| Conditions | 7 | 
| Paths | 7 | 
| Total Lines | 26 | 
| Code Lines | 22 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 16 | 
| CRAP Score | 7 | 
| Changes | 3 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php  | 
            ||
| 57 | 7 | private function cast($value, $type)  | 
            |
| 58 |     { | 
            ||
| 59 |         switch ($type) { | 
            ||
| 60 | 7 | case 'bool':  | 
            |
| 61 | 1 | return boolval($value);  | 
            |
| 62 | break;  | 
            ||
| 63 | 6 | case 'int':  | 
            |
| 64 | 1 | return intval($value);  | 
            |
| 65 | break;  | 
            ||
| 66 | 5 | case 'float':  | 
            |
| 67 | 1 | return floatval($value);  | 
            |
| 68 | break;  | 
            ||
| 69 | 4 | case 'string':  | 
            |
| 70 | 1 | return $value;  | 
            |
| 71 | break;  | 
            ||
| 72 | 3 | case 'array':  | 
            |
| 73 | 1 |                 if (is_array($value)) { | 
            |
| 74 | 1 | return serialize($value);  | 
            |
| 75 |                 } else { | 
            ||
| 76 | 1 | return unserialize($value);  | 
            |
| 77 | }  | 
            ||
| 78 | break;  | 
            ||
| 79 | 2 | default:  | 
            |
| 80 | 2 | return $value;  | 
            |
| 81 | 2 | }  | 
            |
| 82 | }  | 
            ||
| 83 | }  | 
            ||
| 84 | 
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.