1 | <?php |
||
7 | trait Base32 |
||
8 | { |
||
9 | /** |
||
10 | * Generate a digit secret key in base32 format. |
||
11 | * |
||
12 | * @param int $length |
||
13 | * |
||
14 | * @return string |
||
15 | */ |
||
16 | public function generateBase32RandomKey($length = 16, $prefix = '') |
||
30 | |||
31 | /** |
||
32 | * Decodes a base32 string into a binary string. |
||
33 | * |
||
34 | * @param string $b32 |
||
35 | * |
||
36 | * @throws InvalidCharactersException |
||
37 | * |
||
38 | * @return int |
||
39 | */ |
||
40 | public function base32Decode($b32) |
||
48 | |||
49 | /** |
||
50 | * Encode a string to Base32. |
||
51 | * |
||
52 | * @param $string |
||
53 | * |
||
54 | * @return mixed |
||
55 | */ |
||
56 | public function toBase32($string) |
||
62 | } |
||
63 |
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
Idable
provides a methodequalsId
that 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.