@@ -6,7 +6,6 @@ |
||
6 | 6 | use Aws\DynamoDb\Marshaler; |
7 | 7 | use Fathomminds\Rest\Exceptions\RestException; |
8 | 8 | use Fathomminds\Rest\Contracts\IResource; |
9 | -use Fathomminds\Rest\Helpers\Uuid; |
|
10 | 9 | use Aws\DynamoDb\Exception\DynamoDbException; |
11 | 10 | |
12 | 11 | class Resource implements IResource |
@@ -85,6 +85,9 @@ discard block |
||
85 | 85 | return $query; |
86 | 86 | } |
87 | 87 | |
88 | + /** |
|
89 | + * @param DynamoDbException $exception |
|
90 | + */ |
|
88 | 91 | protected function throwAwsPostError($exception) |
89 | 92 | { |
90 | 93 | switch ($exception->getAwsErrorCode()) { |
@@ -121,6 +124,9 @@ discard block |
||
121 | 124 | return $query; |
122 | 125 | } |
123 | 126 | |
127 | + /** |
|
128 | + * @param DynamoDbException $exception |
|
129 | + */ |
|
124 | 130 | protected function throwAwsPutError($exception) |
125 | 131 | { |
126 | 132 | switch ($exception->getAwsErrorCode()) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $indexedFields = array_intersect($uniqueFields, $indexes); //Is unique and value is set and is indexed |
35 | 35 | sort($uniqueFields); |
36 | 36 | sort($indexedFields); |
37 | - return $uniqueFields===$indexedFields; |
|
37 | + return $uniqueFields === $indexedFields; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | protected function scanUniqueFields($fields) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $filter = $this->generateScanFilter($fields); |
61 | 61 | if (property_exists($this->resource, $this->primaryKey)) { |
62 | 62 | $marshaler = new Marshaler; |
63 | - $filter['FilterExpression'] = '('.$filter['FilterExpression'].') AND #pk<>:pk'; |
|
63 | + $filter['FilterExpression'] = '(' . $filter['FilterExpression'] . ') AND #pk<>:pk'; |
|
64 | 64 | $filter['ExpressionAttributeNames']['#pk'] = $this->primaryKey; |
65 | 65 | $filter['ExpressionAttributeValues'][':pk'] = $marshaler->marshalValue( |
66 | 66 | $this->resource->{$this->primaryKey} |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | ]; |
85 | 85 | foreach ($fields as $field) { |
86 | 86 | if (property_exists($this->resource, $field)) { |
87 | - $ret['FilterExpression'] .= '#'.$field.'=:'.$field.' OR '; |
|
88 | - $ret['ExpressionAttributeNames']['#'.$field] = $field; |
|
89 | - $ret['ExpressionAttributeValues'][':'.$field] = $marshaler->marshalValue( |
|
87 | + $ret['FilterExpression'] .= '#' . $field . '=:' . $field . ' OR '; |
|
88 | + $ret['ExpressionAttributeNames']['#' . $field] = $field; |
|
89 | + $ret['ExpressionAttributeValues'][':' . $field] = $marshaler->marshalValue( |
|
90 | 90 | $this->resource->{$field} |
91 | 91 | ); |
92 | 92 | } |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | $marshaler = new Marshaler; |
131 | 131 | $query = [ |
132 | 132 | 'TableName' => $this->database->getDatabaseName() . '-' . $this->resourceName, |
133 | - 'KeyConditionExpression' => '#'.$field.'=:'.$field, |
|
133 | + 'KeyConditionExpression' => '#' . $field . '=:' . $field, |
|
134 | 134 | 'IndexName' => $this->indexNames[$field], |
135 | - 'ExpressionAttributeNames' => ['#'.$field => $field], |
|
136 | - 'ExpressionAttributeValues' => [':'.$field => $marshaler->marshalValue( |
|
135 | + 'ExpressionAttributeNames' => ['#' . $field => $field], |
|
136 | + 'ExpressionAttributeValues' => [':' . $field => $marshaler->marshalValue( |
|
137 | 137 | $this->resource->{$field} |
138 | 138 | )], |
139 | 139 | ]; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | protected function generatePromise($client, $request) |
161 | 161 | { |
162 | 162 | $promise = new Promise( |
163 | - function () use (&$promise, $client, $request) { |
|
163 | + function() use (&$promise, $client, $request) { |
|
164 | 164 | $query = new Query($client, $request); |
165 | 165 | while ($res = $query->next()) { |
166 | 166 | if ($res['Count'] !== 0) { |