1 | <?php |
||
10 | class Builder |
||
11 | { |
||
12 | /** |
||
13 | * The base query builder implementation. |
||
14 | * |
||
15 | * @var \Magister\Services\Database\Query\Builder |
||
16 | */ |
||
17 | protected $query; |
||
18 | |||
19 | /** |
||
20 | * The model being queried. |
||
21 | * |
||
22 | * @var \Magister\Services\Database\Elegant\Model |
||
23 | */ |
||
24 | protected $model; |
||
25 | |||
26 | /** |
||
27 | * Create a new elegant builder instance. |
||
28 | * |
||
29 | * @param \Magister\Services\Database\Query\Builder $query |
||
30 | */ |
||
31 | public function __construct(QueryBuilder $query) |
||
35 | |||
36 | /** |
||
37 | * Find a model by its primary key. |
||
38 | * |
||
39 | * @param mixed $id |
||
40 | * |
||
41 | * @return \Magister\Services\Database\Elegant\Model|\Magister\Services\Support\Collection|null |
||
42 | */ |
||
43 | public function find($id) |
||
47 | |||
48 | /** |
||
49 | * Execute the query and get the first result. |
||
50 | * |
||
51 | * @return \Magister\Services\Database\Elegant\Model|static|null |
||
52 | */ |
||
53 | public function first() |
||
57 | |||
58 | /** |
||
59 | * Execute the query as a select statement. |
||
60 | * |
||
61 | * @return \Magister\Services\Support\Collection|static[] |
||
62 | */ |
||
63 | public function get() |
||
69 | |||
70 | /** |
||
71 | * Pluck a single column from the database. |
||
72 | * |
||
73 | * @param string $column |
||
74 | * |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function pluck($column) |
||
85 | |||
86 | /** |
||
87 | * Get an array with the values of a given column. |
||
88 | * |
||
89 | * @param string $column |
||
90 | * @param string $key |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | public function lists($column, $key = null) |
||
98 | |||
99 | /** |
||
100 | * Get the hydrated models. |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | public function getModels() |
||
112 | |||
113 | /** |
||
114 | * Get the underlying query builder instance. |
||
115 | * |
||
116 | * @return \Magister\Services\Database\Query\Builder|static |
||
117 | */ |
||
118 | public function getQuery() |
||
122 | |||
123 | /** |
||
124 | * Set the underlying query builder instance. |
||
125 | * |
||
126 | * @param \Magister\Services\Database\Query\Builder $query |
||
127 | * |
||
128 | * @return $this |
||
129 | */ |
||
130 | public function setQuery($query) |
||
136 | |||
137 | /** |
||
138 | * Set the model instance being queried. |
||
139 | * |
||
140 | * @param \Magister\Services\Database\Elegant\Model $model |
||
141 | * |
||
142 | * @return $this |
||
143 | */ |
||
144 | public function setModel(Model $model) |
||
152 | |||
153 | /** |
||
154 | * Get the model instance being queried. |
||
155 | * |
||
156 | * @return \Magister\Services\Database\Elegant\Model |
||
157 | */ |
||
158 | public function getModel() |
||
162 | |||
163 | /** |
||
164 | * Dynamically handle calls into the query instance. |
||
165 | * |
||
166 | * @param string $method |
||
167 | * @param array $parameters |
||
168 | * |
||
169 | * @return mixed |
||
170 | */ |
||
171 | public function __call($method, $parameters) |
||
177 | } |
||
178 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.