Skip to content

Commit fac7a95

Browse files
committed
tidy
1 parent 8968ed3 commit fac7a95

File tree

4 files changed

+90
-50
lines changed

4 files changed

+90
-50
lines changed

src/Kitar/Dynamodb/Connection.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,39 @@ public function table($table, $as = null)
3636
return $query->from($table, $as);
3737
}
3838

39+
/**
40+
* @inheritdoc
41+
*/
42+
public function getDriverName()
43+
{
44+
return 'dynamodb';
45+
}
46+
3947
/**
4048
* Get the DynamoDB Client object.
4149
* @return \Aws\Dynamodb\DynamoDbClient
4250
*/
43-
public function getDynamodbClient()
51+
public function getClient()
4452
{
4553
return $this->client;
4654
}
4755

4856
/**
49-
* @inheritdoc
57+
* Set the DynamoDB client.
58+
* @param DynamoDbClient $client
59+
* @return void
5060
*/
51-
public function getDriverName()
61+
public function setClient(DynamoDbClient $client)
5262
{
53-
return 'dynamodb';
63+
$this->client = $client;
5464
}
5565

5666
/**
5767
* Create a new MongoDB client.
5868
* @param array $config
5969
* @return \Aws\Dynamodb\DynamoDbClient
6070
*/
61-
public function createClient(array $config)
71+
protected function createClient(array $config)
6272
{
6373
$sdk = new AwsSdk([
6474
'region' => $config['region'] ?? 'us-east-1',
@@ -72,16 +82,6 @@ public function createClient(array $config)
7282
return $sdk->createDynamoDb();
7383
}
7484

75-
/**
76-
* Set the DynamoDB client.
77-
* @param DynamoDbClient $client
78-
* @return void
79-
*/
80-
public function setClient(DynamoDbClient $client)
81-
{
82-
$this->client = $client;
83-
}
84-
8585
/**
8686
* @inheritdoc
8787
*/

src/Kitar/Dynamodb/Query/Builder.php

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ class Builder extends BaseBuilder
3535

3636
/**
3737
* The key/values to update.
38+
* @var array
3839
*/
3940
public $updates = [
4041
'set' => [],
4142
'remove' => []
4243
];
4344

4445
/**
45-
* LastEvaluatedKey attribute.
46+
* LastEvaluatedKey option.
4647
* @var array|null
4748
*/
4849
public $exclusive_start_key;
@@ -60,10 +61,7 @@ class Builder extends BaseBuilder
6061
public $dry_run = false;
6162

6263
/**
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.
6765
* @var string|null
6866
*/
6967
public $model_class;
@@ -72,40 +70,47 @@ class Builder extends BaseBuilder
7270
* The ExpressionAttributes object.
7371
* @var Kitar\Dynamodb\Query\ExpressionAttributes
7472
*/
75-
public $expression_attributes;
73+
protected $expression_attributes;
7674

7775
/**
7876
* Available where methods which will pass to dedicated queries.
7977
* @var array
8078
*/
81-
public $available_wheres;
79+
protected $available_wheres;
8280

8381
/**
8482
* The attribute name to place compiled wheres.
8583
* @var string
8684
*/
87-
public $where_as;
85+
protected $where_as;
8886

8987
/**
9088
* Dedicated query for building FilterExpression.
9189
* @var Kitar\Dynamodb\Query\Builder
9290
*/
93-
public $filter_query;
91+
protected $filter_query;
9492

9593
/**
9694
* Dedicated query for building ConditionExpression.
9795
* @var Kitar\Dynamodb\Query\Builder
9896
*/
99-
public $condition_query;
97+
protected $condition_query;
10098

10199
/**
102100
* Dedicated query for building KeyConditionExpression.
103101
* @var Kitar\Dynamodb\Query\Builder
104102
*/
105-
public $key_condition_query;
103+
protected $key_condition_query;
106104

107105
/**
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
109114
*/
110115
public function __construct(Connection $connection, Grammar $grammar, Processor $processor, $expression_attributes = null, $is_nested_query = false)
111116
{
@@ -124,6 +129,7 @@ public function __construct(Connection $connection, Grammar $grammar, Processor
124129

125130
/**
126131
* Set the index name.
132+
*
127133
* @param string $index
128134
* @return $this
129135
*/
@@ -136,6 +142,7 @@ public function index(string $index)
136142

137143
/**
138144
* Set the key.
145+
*
139146
* @param array $key
140147
* @return $this
141148
*/
@@ -148,7 +155,6 @@ public function key(array $key)
148155

149156
/**
150157
* Set the ExclusiveStartKey option.
151-
* Unlike other methods, this $key should be marshaled beforehand.
152158
*
153159
* @param array $key
154160
* @return $this
@@ -162,6 +168,7 @@ public function exclusiveStartKey($key)
162168

163169
/**
164170
* Set the ConsistentRead option.
171+
*
165172
* @param bool $active
166173
* @return $this
167174
*/
@@ -173,7 +180,8 @@ public function consistentRead($active = true)
173180
}
174181

175182
/**
176-
* Set the dry run option. It'll return compiled params instead of calling DynamoDB.
183+
* Set the dry run option.
184+
*
177185
* @param bool $active
178186
* @return $this
179187
*/
@@ -185,11 +193,11 @@ public function dryRun($active = true)
185193
}
186194

187195
/**
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).
191198
*
192-
* @var string|null
199+
* @var string
200+
* @return $this
193201
*/
194202
public function usingModel($class_name)
195203
{
@@ -200,20 +208,32 @@ public function usingModel($class_name)
200208

201209
/**
202210
* Set key name of wheres. eg. FilterExpression
211+
*
203212
* @param string $condition_key_name
204213
* @return $this
205214
*/
206-
public function whereAs($condition_key_name)
215+
protected function whereAs($condition_key_name)
207216
{
208217
$this->where_as = $condition_key_name;
209218

210219
return $this;
211220
}
212221

222+
/**
223+
* Get the where_as attribute.
224+
*
225+
* @return string
226+
*/
227+
public function getWhereAs()
228+
{
229+
return $this->where_as;
230+
}
231+
213232
/**
214233
* Get item.
234+
*
215235
* @param array|null $key
216-
* @return Illuminate\Support\Collection|null
236+
* @return array|null
217237
*/
218238
public function getItem($key = null)
219239
{
@@ -226,6 +246,7 @@ public function getItem($key = null)
226246

227247
/**
228248
* Put item.
249+
*
229250
* @param array $item
230251
* @return \Aws\Result
231252
*/
@@ -238,22 +259,22 @@ public function putItem($item)
238259

239260
/**
240261
* Delete item.
241-
* @param array $key|null;
242-
* @return \Aws\Result;
262+
*
263+
* @param array $key;
264+
* @return \Aws\Result
243265
*/
244266
public function deleteItem($key)
245267
{
246-
if ($key) {
247-
$this->key($key);
248-
}
268+
$this->key($key);
249269

250270
return $this->process('deleteItem', null);
251271
}
252272

253273
/**
254274
* Update item.
255-
* @param mixed $item
256-
* @return void
275+
*
276+
* @param array $item
277+
* @return \Aws\Result
257278
*/
258279
public function updateItem($item)
259280
{
@@ -276,7 +297,8 @@ public function updateItem($item)
276297

277298
/**
278299
* Query.
279-
* @return Illuminate\Support\Collection
300+
*
301+
* @return Illuminate\Support\Collection|array
280302
*/
281303
public function query()
282304
{
@@ -285,19 +307,22 @@ public function query()
285307

286308
/**
287309
* Scan.
288-
* @return Illuminate\Support\Collection
310+
*
311+
* @return Illuminate\Support\Collection|array
289312
*/
290313
public function scan()
291314
{
292315
return $this->process('scan', 'processMultipleItems');
293316
}
294317

295318
/**
296-
* Make individual Builder instance for condition types. (Filter, Condition and KeyCondition)
319+
* Make individual Builder instance for condition types.
320+
*
297321
* @return void
298322
*/
299-
public function initializeDedicatedQueries()
323+
protected function initializeDedicatedQueries()
300324
{
325+
// Set builder instances.
301326
$this->filter_query = $this->newQuery()->whereAs('FilterExpression');
302327
$this->condition_query = $this->newQuery()->whereAs('ConditionExpression');
303328
$this->key_condition_query = $this->newQuery()->whereAs('KeyConditionExpression');
@@ -319,6 +344,7 @@ public function initializeDedicatedQueries()
319344

320345
/**
321346
* Perform where methods within dedicated queries.
347+
*
322348
* @param string $method
323349
* @param array $parameters
324350
* @return $this
@@ -431,6 +457,7 @@ public function newQuery()
431457

432458
/**
433459
* Execute DynamoDB call and returns processed result.
460+
*
434461
* @param string $query_method
435462
* @param array $params
436463
* @param string $processor_method

0 commit comments

Comments
 (0)