1 | <?php |
||
9 | trait Searchable |
||
10 | { |
||
11 | private $moduleSearchPage = 'SearchPage'; |
||
12 | |||
13 | /** |
||
14 | * @return string |
||
15 | */ |
||
16 | abstract protected function getScope(); |
||
17 | |||
18 | /** |
||
19 | * Executes search to API. Query - search string. |
||
20 | * |
||
21 | * @param string $query |
||
22 | * @param string $scope |
||
23 | * @param array $bookmarks |
||
24 | * |
||
25 | * @return array |
||
26 | */ |
||
27 | public function searchCall($query, $scope, $bookmarks = []) |
||
46 | |||
47 | /** |
||
48 | * Creates Pinterest API search request. |
||
49 | * |
||
50 | * @param $query |
||
51 | * @param $scope |
||
52 | * @param array $bookmarks |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | protected function createSearchQuery($query, $scope, $bookmarks = []) |
||
63 | |||
64 | /** |
||
65 | * Search entities by search query. |
||
66 | * |
||
67 | * @param string $query |
||
68 | * @param int $limit |
||
69 | * |
||
70 | * @return \Iterator |
||
71 | */ |
||
72 | public function search($query, $limit = 0) |
||
81 | |||
82 | /** |
||
83 | * @param $bookmarks |
||
84 | * @param $options |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | protected function appendBookMarks($bookmarks, $options) |
||
108 | |||
109 | /** |
||
110 | * Parses simple Pinterest search API response |
||
111 | * on request with bookmarks. |
||
112 | * |
||
113 | * @param array $response |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | protected function parseSearchResult($response) |
||
131 | } |
||
132 |
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.