| 1 | <?php |
||
| 5 | trait Memcache |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Permet de savoir si la clé existe |
||
| 9 | * |
||
| 10 | * @param string $key la clé disignant les infos concernées |
||
| 11 | * |
||
| 12 | * @throws \Exception Erreur dsans les paramètres donnée à la méthode |
||
| 13 | * |
||
| 14 | * @return bool |
||
| 15 | */ |
||
| 16 | public function ifExists($key) |
||
| 29 | |||
| 30 | /** |
||
| 31 | * On modifie le temps avant expiration des infos sur |
||
| 32 | * le serveur memcached pour une clé choisie. |
||
| 33 | * |
||
| 34 | * @param string $key la clé disignant les infos concerné |
||
| 35 | * @param int $expire le nouveau temps avant expiration |
||
| 36 | * (0: pas d'expiration, max 30jours) |
||
| 37 | * |
||
| 38 | * @throws \Exception Erreur dsans les paramètres donnée à la méthode |
||
| 39 | * |
||
| 40 | * @return boolean|null |
||
| 41 | */ |
||
| 42 | public function majExpire($key, $expire) |
||
| 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.