1 | <?php |
||
2 | |||
3 | namespace Bdf\Prime\Query; |
||
4 | |||
5 | use Bdf\Prime\Collection\CollectionFactory; |
||
6 | use Bdf\Prime\Collection\CollectionInterface; |
||
7 | use Bdf\Prime\Exception\PrimeException; |
||
8 | use Bdf\Prime\Query\Contract\Cachable; |
||
9 | use Bdf\Prime\Query\Contract\ReadOperation; |
||
10 | |||
11 | /** |
||
12 | * Base type for "read" operation commands |
||
13 | * |
||
14 | * @method $this by(string $attribute, bool $combine = false) Indexing entities by an attribute value. Use combine for multiple entities with same attribute value |
||
15 | * @method $this with(string|string[] $relations) Relations to load |
||
16 | * @method $this without(string|string[] $relations) Relations to discard |
||
17 | * @method R|null get($pk) Get one entity by its identifier |
||
18 | * @method R getOrFail($pk) Get one entity or throws when entity is not found |
||
19 | * @method R getOrNew($pk) Get one entity or return a new one if not found in repository |
||
20 | * |
||
21 | * @template C as \Bdf\Prime\Connection\ConnectionInterface |
||
22 | * @template R as object|array |
||
23 | * |
||
24 | * @extends CommandInterface<C> |
||
25 | */ |
||
26 | interface ReadCommandInterface extends CommandInterface, Cachable |
||
27 | { |
||
28 | /** |
||
29 | * Register an object that can extends the Query methods. |
||
30 | * The extension will be called when the method cannot be found on the query object. |
||
31 | * |
||
32 | * <pre><code> |
||
33 | * class MyExtension { |
||
34 | * public function myCustomMethod(QueryInterface $query, $param) |
||
35 | * { |
||
36 | * $query->where(...); |
||
37 | * return $query; |
||
38 | * } |
||
39 | * } |
||
40 | * |
||
41 | * $query->setExtension(new MyExtension()); |
||
42 | * |
||
43 | * $query->myCustomMethod(...); // Will call MyExtension->myCustomMethod() |
||
44 | * </pre></code> |
||
45 | * |
||
46 | * @param object $extension |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public function setExtension($extension): void; |
||
51 | |||
52 | /** |
||
53 | * Get the collection factory |
||
54 | * |
||
55 | * @return CollectionFactory |
||
56 | */ |
||
57 | public function collectionFactory(): CollectionFactory; |
||
58 | |||
59 | /** |
||
60 | * Set the collection factory |
||
61 | * |
||
62 | * @param CollectionFactory $collectionFactory |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function setCollectionFactory(CollectionFactory $collectionFactory); |
||
67 | |||
68 | /** |
||
69 | * Set a post processor to transform query result |
||
70 | * |
||
71 | * @param (EACH is true ? callable(array<string, mixed>):mixed : callable(\Bdf\Prime\Connection\Result\ResultSetInterface<array<string, mixed>>):array) $processor |
||
0 ignored issues
–
show
|
|||
72 | * @param EACH $forEach |
||
0 ignored issues
–
show
The type
Bdf\Prime\Query\EACH was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
73 | * |
||
74 | * @return $this |
||
75 | * |
||
76 | * @template EACH as bool |
||
77 | */ |
||
78 | public function post(callable $processor, bool $forEach = true); |
||
79 | |||
80 | /** |
||
81 | * Set the collection class |
||
82 | * |
||
83 | * @param string $wrapperClass |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function wrapAs(string $wrapperClass); |
||
88 | |||
89 | /** |
||
90 | * Get all matched data. |
||
91 | * The all method run the post processors |
||
92 | * |
||
93 | * <code> |
||
94 | * $query |
||
95 | * ->from('users') |
||
96 | * ->all('name); |
||
97 | * </code> |
||
98 | * |
||
99 | * @param string|array $columns |
||
100 | * |
||
101 | * @return R[]|CollectionInterface<R> |
||
102 | * |
||
103 | * @throws PrimeException When execute fail |
||
104 | */ |
||
105 | #[ReadOperation] |
||
106 | public function all($columns = null); |
||
107 | |||
108 | /** |
||
109 | * Get first matched data |
||
110 | * |
||
111 | * <code> |
||
112 | * $query |
||
113 | * ->from('users') |
||
114 | * ->first('name); |
||
115 | * </code> |
||
116 | * |
||
117 | * @param string|array $columns |
||
118 | * |
||
119 | * @return R|null |
||
120 | * @throws PrimeException When execute fail |
||
121 | */ |
||
122 | #[ReadOperation] |
||
123 | public function first($columns = null); |
||
124 | |||
125 | /** |
||
126 | * Get a collection of column value |
||
127 | * |
||
128 | * <code> |
||
129 | * $result = $query |
||
130 | * ->from('users') |
||
131 | * ->inRows('name); |
||
132 | * |
||
133 | * print_r($result); |
||
134 | * // display |
||
135 | * Array |
||
136 | * ( |
||
137 | * [0] => 'foo' |
||
138 | * [1] => 'bar' |
||
139 | * ... |
||
140 | * </code> |
||
141 | * |
||
142 | * @param string $column |
||
143 | * |
||
144 | * @return list<mixed> |
||
0 ignored issues
–
show
The type
Bdf\Prime\Query\list was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
145 | * @throws PrimeException When execute fail |
||
146 | */ |
||
147 | #[ReadOperation] |
||
148 | public function inRows(string $column): array; |
||
149 | |||
150 | /** |
||
151 | * Get a column value |
||
152 | * |
||
153 | * <code> |
||
154 | * $result = $query |
||
155 | * ->from('users') |
||
156 | * ->inRow('name); |
||
157 | * |
||
158 | * echo $result; |
||
159 | * // display 'foo' |
||
160 | * </code> |
||
161 | * |
||
162 | * @param string $column |
||
163 | * |
||
164 | * @return mixed |
||
165 | * @throws PrimeException When execute fail |
||
166 | */ |
||
167 | #[ReadOperation] |
||
168 | public function inRow(string $column); |
||
169 | } |
||
170 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths