| 1 | <?php |
||
| 9 | trait HasUniqueIdTrait |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var null|string |
||
| 13 | */ |
||
| 14 | protected $_uniqueID = null; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @return string |
||
| 18 | */ |
||
| 19 | public function getJSID() |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return null|string |
||
| 28 | */ |
||
| 29 | 5 | public function getUniqueId() |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @param null|string $uniqueID |
||
| 40 | */ |
||
| 41 | 5 | public function setUniqueID($uniqueID) |
|
| 45 | |||
| 46 | 5 | protected function initUniqueId() |
|
| 50 | |||
| 51 | /** |
||
| 52 | * @return null|string |
||
| 53 | */ |
||
| 54 | 5 | protected function generateUniqueId() |
|
| 66 | } |
||
| 67 |
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.