| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 27 | 
| Code Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 18 | 
| CRAP Score | 4 | 
| Changes | 3 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 29 | 15 | public function pref($key, $value = null, $type = 'string')  | 
            |
| 30 |     { | 
            ||
| 31 | 15 |         if (isset($value)) { | 
            |
| 32 | 10 | $this->preferences()->updateOrCreate(['key' => $key], ['value' => $this->cast($value, $type),  | 
            |
| 33 | 10 | 'type' => $type, ]);  | 
            |
| 34 | |||
| 35 | 10 |             Cache::put("{$this->slug}.'/'.{$key}", $value, 60); | 
            |
| 36 | 10 | return $value;  | 
            |
| 37 | }  | 
            ||
| 38 | |||
| 39 | 15 |         if($value = Cache::get("{$this->slug}.'/'.{$key}")) | 
            |
| 40 | 15 |         { | 
            |
| 41 | 10 | return $value;  | 
            |
| 42 | }  | 
            ||
| 43 | |||
| 44 | 6 |         if ($pref = $this->preferences()->forKey($key)->first()) { | 
            |
| 45 | 1 | $value = $pref->value();  | 
            |
| 46 | 1 | $type = $pref->type();  | 
            |
| 47 | 1 |         } else { | 
            |
| 48 | 5 | $default = Preference::getDefault($this, $key);  | 
            |
| 49 | 5 | $value = $default->value();  | 
            |
| 50 | 5 | $type = $default->type();  | 
            |
| 51 | }  | 
            ||
| 52 | |||
| 53 | 6 |         Cache::put("{$this->slug}.'/'.{$key}", $value, 60); | 
            |
| 54 | 6 | return $this->cast($value, $type);  | 
            |
| 55 | }  | 
            ||
| 56 | |||
| 92 | 
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.