1 | <?php |
||
10 | trait Elasticsearchable |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected static $index; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected static $type; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected static $parentType; |
||
26 | |||
27 | /** |
||
28 | * @var InnerHits |
||
29 | */ |
||
30 | public $_innerHits; |
||
31 | |||
32 | /** |
||
33 | * @var float |
||
34 | */ |
||
35 | public $_score; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | public $_position; |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | final public static function getIndex() |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | final public static function getType() |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | final public static function getParentType() |
||
65 | |||
66 | /** |
||
67 | * @throws InvalidModelEndpointException |
||
68 | */ |
||
69 | final protected function validateModelEndpoint() |
||
83 | |||
84 | /** |
||
85 | * @param InnerHits $innerHits |
||
86 | */ |
||
87 | protected function setInnerHits(InnerHits $innerHits) |
||
91 | |||
92 | /** |
||
93 | * @return InnerHits |
||
94 | */ |
||
95 | protected function getInnerHits() |
||
99 | |||
100 | /** |
||
101 | * @param array $response |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function fillByResponse(array $response) |
||
111 | |||
112 | /** |
||
113 | * @param array $response |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function fillByInnerHits(array $response) |
||
123 | |||
124 | public function getPath() |
||
128 | |||
129 | public function getPosition() |
||
133 | } |
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.