1 | <?php |
||
19 | trait ExecutionsProvider |
||
20 | { |
||
21 | /** |
||
22 | * @param string ...$fields |
||
23 | * @return object[]|iterable |
||
24 | */ |
||
25 | public function get(string ...$fields): iterable |
||
45 | |||
46 | /** |
||
47 | * @param string $field |
||
48 | * @param string|null $typeOf |
||
49 | * @return mixed |
||
50 | * @throws \LogicException |
||
51 | */ |
||
52 | public function scalar(string $field, string $typeOf = null) |
||
62 | |||
63 | /** |
||
64 | * @param mixed $result |
||
65 | * @param string $typeOf |
||
66 | * @return array|\Closure|object |
||
67 | */ |
||
68 | private function cast($result, string $typeOf) |
||
94 | |||
95 | /** |
||
96 | * @param string|null $field |
||
97 | * @return int |
||
98 | * @throws \LogicException |
||
99 | */ |
||
100 | public function count(?string $field = 'id'): int |
||
105 | |||
106 | /** |
||
107 | * @param string|null $field |
||
108 | * @return int |
||
109 | * @throws \LogicException |
||
110 | */ |
||
111 | public function sum(string $field = null): int |
||
116 | |||
117 | /** |
||
118 | * @param string|null $field |
||
119 | * @return int |
||
120 | * @throws \LogicException |
||
121 | */ |
||
122 | public function avg(string $field = null): int |
||
127 | |||
128 | /** |
||
129 | * @param string|null $field |
||
130 | * @return int |
||
131 | * @throws \LogicException |
||
132 | */ |
||
133 | public function max(string $field = null): int |
||
138 | |||
139 | /** |
||
140 | * @param string|null $field |
||
141 | * @return int |
||
142 | * @throws \LogicException |
||
143 | */ |
||
144 | public function min(string $field = null): int |
||
149 | |||
150 | /** |
||
151 | * @param string ...$fields |
||
152 | * @return Collection |
||
153 | */ |
||
154 | public function collect(string ...$fields): Collection |
||
158 | |||
159 | /** |
||
160 | * @param string[] $fields |
||
161 | * @return object|null |
||
162 | * @throws \LogicException |
||
163 | */ |
||
164 | public function first(string ...$fields) |
||
168 | } |
||
169 |
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.