@@ -35,14 +35,15 @@ class Builder extends BaseBuilder
35
35
36
36
/**
37
37
* The key/values to update.
38
+ * @var array
38
39
*/
39
40
public $ updates = [
40
41
'set ' => [],
41
42
'remove ' => []
42
43
];
43
44
44
45
/**
45
- * LastEvaluatedKey attribute .
46
+ * LastEvaluatedKey option .
46
47
* @var array|null
47
48
*/
48
49
public $ exclusive_start_key ;
@@ -60,10 +61,7 @@ class Builder extends BaseBuilder
60
61
public $ dry_run = false ;
61
62
62
63
/**
63
- * ** experimental **
64
- * If set, all response items will be converted to
65
- * this class using (new $model_class)->newFromBuilder($item).
66
- *
64
+ * The model class name used to transform the DynamoDB responses.
67
65
* @var string|null
68
66
*/
69
67
public $ model_class ;
@@ -72,40 +70,47 @@ class Builder extends BaseBuilder
72
70
* The ExpressionAttributes object.
73
71
* @var Kitar\Dynamodb\Query\ExpressionAttributes
74
72
*/
75
- public $ expression_attributes ;
73
+ protected $ expression_attributes ;
76
74
77
75
/**
78
76
* Available where methods which will pass to dedicated queries.
79
77
* @var array
80
78
*/
81
- public $ available_wheres ;
79
+ protected $ available_wheres ;
82
80
83
81
/**
84
82
* The attribute name to place compiled wheres.
85
83
* @var string
86
84
*/
87
- public $ where_as ;
85
+ protected $ where_as ;
88
86
89
87
/**
90
88
* Dedicated query for building FilterExpression.
91
89
* @var Kitar\Dynamodb\Query\Builder
92
90
*/
93
- public $ filter_query ;
91
+ protected $ filter_query ;
94
92
95
93
/**
96
94
* Dedicated query for building ConditionExpression.
97
95
* @var Kitar\Dynamodb\Query\Builder
98
96
*/
99
- public $ condition_query ;
97
+ protected $ condition_query ;
100
98
101
99
/**
102
100
* Dedicated query for building KeyConditionExpression.
103
101
* @var Kitar\Dynamodb\Query\Builder
104
102
*/
105
- public $ key_condition_query ;
103
+ protected $ key_condition_query ;
106
104
107
105
/**
108
- * @inheritdoc
106
+ * Create a new query builder instance.
107
+ *
108
+ * @param Kitar\Dynamodb\Connection $connection
109
+ * @param Kitar\Dynamodb\Query\Grammar $grammar
110
+ * @param Kitar\Dynamodb\Query\Processor $processor
111
+ * @param Kitar\Dynamodb\Query\ExpressionAttributes|null $expression_attributes
112
+ * @param bool $is_nested_query
113
+ * @return void
109
114
*/
110
115
public function __construct (Connection $ connection , Grammar $ grammar , Processor $ processor , $ expression_attributes = null , $ is_nested_query = false )
111
116
{
@@ -124,6 +129,7 @@ public function __construct(Connection $connection, Grammar $grammar, Processor
124
129
125
130
/**
126
131
* Set the index name.
132
+ *
127
133
* @param string $index
128
134
* @return $this
129
135
*/
@@ -136,6 +142,7 @@ public function index(string $index)
136
142
137
143
/**
138
144
* Set the key.
145
+ *
139
146
* @param array $key
140
147
* @return $this
141
148
*/
@@ -148,7 +155,6 @@ public function key(array $key)
148
155
149
156
/**
150
157
* Set the ExclusiveStartKey option.
151
- * Unlike other methods, this $key should be marshaled beforehand.
152
158
*
153
159
* @param array $key
154
160
* @return $this
@@ -162,6 +168,7 @@ public function exclusiveStartKey($key)
162
168
163
169
/**
164
170
* Set the ConsistentRead option.
171
+ *
165
172
* @param bool $active
166
173
* @return $this
167
174
*/
@@ -173,7 +180,8 @@ public function consistentRead($active = true)
173
180
}
174
181
175
182
/**
176
- * Set the dry run option. It'll return compiled params instead of calling DynamoDB.
183
+ * Set the dry run option.
184
+ *
177
185
* @param bool $active
178
186
* @return $this
179
187
*/
@@ -185,11 +193,11 @@ public function dryRun($active = true)
185
193
}
186
194
187
195
/**
188
- * ** experimental **
189
- * If set, all response items will be converted to
190
- * this class using (new $model_class)->newFromBuilder($item).
196
+ * If set, response items will be converted to the model instance by using:
197
+ * (new $model_class)->newFromBuilder($item).
191
198
*
192
- * @var string|null
199
+ * @var string
200
+ * @return $this
193
201
*/
194
202
public function usingModel ($ class_name )
195
203
{
@@ -200,20 +208,32 @@ public function usingModel($class_name)
200
208
201
209
/**
202
210
* Set key name of wheres. eg. FilterExpression
211
+ *
203
212
* @param string $condition_key_name
204
213
* @return $this
205
214
*/
206
- public function whereAs ($ condition_key_name )
215
+ protected function whereAs ($ condition_key_name )
207
216
{
208
217
$ this ->where_as = $ condition_key_name ;
209
218
210
219
return $ this ;
211
220
}
212
221
222
+ /**
223
+ * Get the where_as attribute.
224
+ *
225
+ * @return string
226
+ */
227
+ public function getWhereAs ()
228
+ {
229
+ return $ this ->where_as ;
230
+ }
231
+
213
232
/**
214
233
* Get item.
234
+ *
215
235
* @param array|null $key
216
- * @return Illuminate\Support\Collection |null
236
+ * @return array |null
217
237
*/
218
238
public function getItem ($ key = null )
219
239
{
@@ -226,6 +246,7 @@ public function getItem($key = null)
226
246
227
247
/**
228
248
* Put item.
249
+ *
229
250
* @param array $item
230
251
* @return \Aws\Result
231
252
*/
@@ -238,22 +259,22 @@ public function putItem($item)
238
259
239
260
/**
240
261
* Delete item.
241
- * @param array $key|null;
242
- * @return \Aws\Result;
262
+ *
263
+ * @param array $key;
264
+ * @return \Aws\Result
243
265
*/
244
266
public function deleteItem ($ key )
245
267
{
246
- if ($ key ) {
247
- $ this ->key ($ key );
248
- }
268
+ $ this ->key ($ key );
249
269
250
270
return $ this ->process ('deleteItem ' , null );
251
271
}
252
272
253
273
/**
254
274
* Update item.
255
- * @param mixed $item
256
- * @return void
275
+ *
276
+ * @param array $item
277
+ * @return \Aws\Result
257
278
*/
258
279
public function updateItem ($ item )
259
280
{
@@ -276,7 +297,8 @@ public function updateItem($item)
276
297
277
298
/**
278
299
* Query.
279
- * @return Illuminate\Support\Collection
300
+ *
301
+ * @return Illuminate\Support\Collection|array
280
302
*/
281
303
public function query ()
282
304
{
@@ -285,19 +307,22 @@ public function query()
285
307
286
308
/**
287
309
* Scan.
288
- * @return Illuminate\Support\Collection
310
+ *
311
+ * @return Illuminate\Support\Collection|array
289
312
*/
290
313
public function scan ()
291
314
{
292
315
return $ this ->process ('scan ' , 'processMultipleItems ' );
293
316
}
294
317
295
318
/**
296
- * Make individual Builder instance for condition types. (Filter, Condition and KeyCondition)
319
+ * Make individual Builder instance for condition types.
320
+ *
297
321
* @return void
298
322
*/
299
- public function initializeDedicatedQueries ()
323
+ protected function initializeDedicatedQueries ()
300
324
{
325
+ // Set builder instances.
301
326
$ this ->filter_query = $ this ->newQuery ()->whereAs ('FilterExpression ' );
302
327
$ this ->condition_query = $ this ->newQuery ()->whereAs ('ConditionExpression ' );
303
328
$ this ->key_condition_query = $ this ->newQuery ()->whereAs ('KeyConditionExpression ' );
@@ -319,6 +344,7 @@ public function initializeDedicatedQueries()
319
344
320
345
/**
321
346
* Perform where methods within dedicated queries.
347
+ *
322
348
* @param string $method
323
349
* @param array $parameters
324
350
* @return $this
@@ -431,6 +457,7 @@ public function newQuery()
431
457
432
458
/**
433
459
* Execute DynamoDB call and returns processed result.
460
+ *
434
461
* @param string $query_method
435
462
* @param array $params
436
463
* @param string $processor_method
0 commit comments