| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | public function majExpire($key, $expire) |
||
| 43 | { |
||
| 44 | $verifParams = verifTypeData([ |
||
| 45 | ['type' => 'string', 'data' => $key], |
||
| 46 | ['type' => 'int', 'data' => $expire] |
||
| 47 | ]); |
||
| 48 | |||
| 49 | if (!$verifParams) { |
||
| 50 | throw new \Exception( |
||
| 51 | 'Once of parameters $key or $expire not have a correct type.' |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | $value = $this->get($key); //Récupère la valeur |
||
| 56 | |||
| 57 | //On la "modifie" en remettant la même valeur mais en changeant |
||
| 58 | //le temps avant expiration |
||
| 59 | $this->replace($key, $value, 0, $expire); |
||
| 60 | |||
| 61 | return true; |
||
| 62 | } |
||
| 63 | } |
||
| 64 |
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.