| 1 | <?php |
||
| 14 | trait HasRelatedTopics |
||
| 15 | { |
||
| 16 | use HandlesRequest; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Returns a list of related topics |
||
| 20 | * @param string $interest |
||
| 21 | * @return array|bool |
||
| 22 | */ |
||
| 23 | public function getRelatedTopics($interest) |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Returns a feed of pins. |
||
| 33 | * |
||
| 34 | * @param string $interest |
||
| 35 | * @param int $limit |
||
| 36 | * @return Generator |
||
| 37 | */ |
||
| 38 | public function getPinsFor($interest, $limit = 0) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param $interest |
||
| 50 | * @return array |
||
| 51 | */ |
||
| 52 | abstract protected function getFeedRequestData($interest); |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | protected function getFeedUrl() |
||
| 61 | } |
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.