@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | public function set($name) |
29 | 29 | { |
30 | 30 | if ($this->isNested($name)) { |
31 | - $this->nested[] = $name; |
|
31 | + $this->nested[ ] = $name; |
|
32 | 32 | return; |
33 | 33 | } |
34 | - $this->mapping["{$this->prefix}{$name}"] = $name; |
|
34 | + $this->mapping[ "{$this->prefix}{$name}" ] = $name; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function get($placeholder) |
38 | 38 | { |
39 | - return $this->mapping[$placeholder]; |
|
39 | + return $this->mapping[ $placeholder ]; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function placeholder($name) |
43 | 43 | { |
44 | 44 | $placeholder = "{$this->prefix}{$name}"; |
45 | - if (isset($this->mapping[$placeholder])) { |
|
45 | + if (isset($this->mapping[ $placeholder ])) { |
|
46 | 46 | return $placeholder; |
47 | 47 | } |
48 | 48 | return $name; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | public function reset() |
62 | 62 | { |
63 | - $this->mapping = []; |
|
64 | - $this->nested = []; |
|
63 | + $this->mapping = [ ]; |
|
64 | + $this->nested = [ ]; |
|
65 | 65 | |
66 | 66 | return $this; |
67 | 67 | } |
@@ -25,6 +25,6 @@ |
||
25 | 25 | $this->names->set($attribute); |
26 | 26 | } |
27 | 27 | |
28 | - return 'REMOVE ' . implode(', ', $this->names->placeholders()); |
|
28 | + return 'REMOVE '.implode(', ', $this->names->placeholders()); |
|
29 | 29 | } |
30 | 30 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return ''; |
70 | 70 | } |
71 | 71 | |
72 | - $parsed = []; |
|
72 | + $parsed = [ ]; |
|
73 | 73 | |
74 | 74 | foreach ($wheres as $condition) { |
75 | 75 | $boolean = array_get($condition, 'boolean'); |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | $prefix = ''; |
80 | 80 | |
81 | 81 | if (count($parsed) > 0) { |
82 | - $prefix = strtoupper($boolean) . ' '; |
|
82 | + $prefix = strtoupper($boolean).' '; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | if ($operator === 'Nested') { |
86 | - $parsed[] = $prefix . $this->parseNestedCondition($value); |
|
86 | + $parsed[ ] = $prefix.$this->parseNestedCondition($value); |
|
87 | 87 | continue; |
88 | 88 | } |
89 | - $parsed[] = $prefix . $this->parseCondition( |
|
89 | + $parsed[ ] = $prefix.$this->parseCondition( |
|
90 | 90 | array_get($condition, 'column'), |
91 | 91 | $operator, |
92 | 92 | $value |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | |
111 | 111 | protected function parseNestedCondition(array $conditions) |
112 | 112 | { |
113 | - return '(' . $this->parse($conditions) . ')'; |
|
113 | + return '('.$this->parse($conditions).')'; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | protected function parseCondition($name, $operator, $value) |
117 | 117 | { |
118 | 118 | $operators = $this->getSupportedOperators(); |
119 | - if (empty($operators[$operator])) { |
|
119 | + if (empty($operators[ $operator ])) { |
|
120 | 120 | throw new NotSupportedException("$operator is not supported"); |
121 | 121 | } |
122 | 122 | |
123 | - $template = $operators[$operator]; |
|
123 | + $template = $operators[ $operator ]; |
|
124 | 124 | |
125 | 125 | $this->names->set($name); |
126 | 126 | |
@@ -149,21 +149,21 @@ discard block |
||
149 | 149 | |
150 | 150 | $second = $this->placeholder->next(); |
151 | 151 | |
152 | - $this->values->set($first, DynamoDb::marshalValue($value[0])); |
|
152 | + $this->values->set($first, DynamoDb::marshalValue($value[ 0 ])); |
|
153 | 153 | |
154 | - $this->values->set($second, DynamoDb::marshalValue($value[1])); |
|
154 | + $this->values->set($second, DynamoDb::marshalValue($value[ 1 ])); |
|
155 | 155 | |
156 | 156 | return sprintf($template, $this->names->placeholder($name), $first, $second); |
157 | 157 | } |
158 | 158 | |
159 | 159 | protected function parseInCondition($name, $value, $template) |
160 | 160 | { |
161 | - $valuePlaceholders = []; |
|
161 | + $valuePlaceholders = [ ]; |
|
162 | 162 | |
163 | 163 | foreach ($value as $item) { |
164 | 164 | $placeholder = $this->placeholder->next(); |
165 | 165 | |
166 | - $valuePlaceholders[] = ":" . $placeholder; |
|
166 | + $valuePlaceholders[ ] = ":".$placeholder; |
|
167 | 167 | |
168 | 168 | $this->values->set($placeholder, DynamoDb::marshalValue($item)); |
169 | 169 | } |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | return $array; |
184 | 184 | } |
185 | 185 | |
186 | - if (isset($array[$key])) { |
|
187 | - return $array[$key]; |
|
186 | + if (isset($array[ $key ])) { |
|
187 | + return $array[ $key ]; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | foreach (explode('.', $key) as $segment) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | return $default; |
193 | 193 | } |
194 | 194 | |
195 | - $array = $array[$segment]; |
|
195 | + $array = $array[ $segment ]; |
|
196 | 196 | } |
197 | 197 | return $array; |
198 | 198 | } |
199 | 199 | \ No newline at end of file |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | |
23 | 23 | public function set($placeholder, $value) |
24 | 24 | { |
25 | - $this->mapping["{$this->prefix}{$placeholder}"] = $value; |
|
25 | + $this->mapping[ "{$this->prefix}{$placeholder}" ] = $value; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function get($placeholder) |
29 | 29 | { |
30 | - return $this->mapping[$placeholder]; |
|
30 | + return $this->mapping[ $placeholder ]; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function all() |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function reset() |
44 | 44 | { |
45 | - $this->mapping = []; |
|
45 | + $this->mapping = [ ]; |
|
46 | 46 | |
47 | 47 | return $this; |
48 | 48 | } |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | 'begins_with' |
15 | 15 | ]; |
16 | 16 | |
17 | - protected $params = []; |
|
18 | - protected $insertParam = []; |
|
17 | + protected $params = [ ]; |
|
18 | + protected $insertParam = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var Builder |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | /** @var \Hoooklife\DynamodbPodm\Grammars\DynamoDBBuilder $dynamoDBBuilder */ |
30 | 30 | private $dynamoDBBuilder; |
31 | 31 | |
32 | - private $attributeValues = []; |
|
33 | - private $attributeNames = []; |
|
32 | + private $attributeValues = [ ]; |
|
33 | + private $attributeNames = [ ]; |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** @var Marshaler $marshaler */ |
@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | // 表达式解析 where |
55 | 55 | private function parseKeyConditionExpression() |
56 | 56 | { |
57 | - $expression = []; |
|
57 | + $expression = [ ]; |
|
58 | 58 | |
59 | 59 | foreach ($this->builder->wheres as $valueIndex => $where) { |
60 | 60 | $columnIndex = count($this->attributeNames); |
61 | - switch (strtolower($where['operator'])) { |
|
61 | + switch (strtolower($where[ 'operator' ])) { |
|
62 | 62 | case "begins_with": |
63 | - $expression[] = "begins_with(#$columnIndex, :{$valueIndex})"; |
|
63 | + $expression[ ] = "begins_with(#$columnIndex, :{$valueIndex})"; |
|
64 | 64 | break; |
65 | 65 | default: |
66 | - $expression[] = "#$columnIndex {$where['operator']} :{$valueIndex}"; |
|
66 | + $expression[ ] = "#$columnIndex {$where[ 'operator' ]} :{$valueIndex}"; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // param bind |
70 | - $this->attributeValues[':' . $valueIndex] = $where['value']; |
|
71 | - $this->attributeNames['#' . $columnIndex] = $where['column']; |
|
70 | + $this->attributeValues[ ':'.$valueIndex ] = $where[ 'value' ]; |
|
71 | + $this->attributeNames[ '#'.$columnIndex ] = $where[ 'column' ]; |
|
72 | 72 | } |
73 | 73 | return implode(" and ", $expression); |
74 | 74 | } |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | // select |
83 | 83 | public function parseProjectionExpression() |
84 | 84 | { |
85 | - $tmp = []; |
|
85 | + $tmp = [ ]; |
|
86 | 86 | foreach ($this->builder->columns as $column) { |
87 | 87 | $index = count($this->attributeNames); |
88 | - $this->attributeNames["#{$index}"] = $column; |
|
89 | - $tmp[] = "#{$index}"; |
|
88 | + $this->attributeNames[ "#{$index}" ] = $column; |
|
89 | + $tmp[ ] = "#{$index}"; |
|
90 | 90 | } |
91 | 91 | return implode(",", $tmp); |
92 | 92 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $this->createInsertParam($data); |
114 | 114 | |
115 | 115 | $builder = $this->dynamoDBBuilder |
116 | - ->setRequestItems([$this->builder->table => $this->insertParam]); |
|
116 | + ->setRequestItems([ $this->builder->table => $this->insertParam ]); |
|
117 | 117 | |
118 | 118 | return $builder->batchWriteItem(); |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | if (is_numeric($key) && is_array($value)) { |
125 | 125 | $this->createInsertParam($value); |
126 | 126 | } else { |
127 | - $this->insertParam[] = [ |
|
127 | + $this->insertParam[ ] = [ |
|
128 | 128 | 'PutRequest' => [ |
129 | 129 | 'Item' => $this->marshaler->marshalItem($data) |
130 | 130 | ] |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | * 查询排序 |
19 | 19 | */ |
20 | 20 | public $limit; |
21 | - public $wheres = []; |
|
22 | - public $bindings = []; |
|
21 | + public $wheres = [ ]; |
|
22 | + public $bindings = [ ]; |
|
23 | 23 | public $columns; |
24 | 24 | public $table; |
25 | 25 | |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | public function __construct($connection = 'default') |
45 | 45 | { |
46 | 46 | $this->setupExpressions(); |
47 | - switch (DB::$config[$connection]['driver']) { |
|
47 | + switch (DB::$config[ $connection ][ 'driver' ]) { |
|
48 | 48 | case "dynamedb": |
49 | - $this->dynamoDBBuilder = new DynamoDBBuilder(DB::$config[$connection]); |
|
50 | - $this->client = new DynamoDbClient(DB::$config[$connection]["S3Config"]); |
|
49 | + $this->dynamoDBBuilder = new DynamoDBBuilder(DB::$config[ $connection ]); |
|
50 | + $this->client = new DynamoDbClient(DB::$config[ $connection ][ "S3Config" ]); |
|
51 | 51 | break; |
52 | 52 | default: |
53 | 53 | throw new \Exception("bad driver"); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | if (func_num_args() === 2 || !ComparisonOperator::isValidOperator($operator)) { |
97 | - list($value, $operator) = [$operator, '=']; |
|
97 | + list($value, $operator) = [ $operator, '=' ]; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // if ($column instanceof Closure) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return $this->whereNull($column, $type, $boolean, $operator !== '='); |
113 | 113 | } |
114 | 114 | |
115 | - $this->wheres[] = [ |
|
115 | + $this->wheres[ ] = [ |
|
116 | 116 | 'column' => $column, |
117 | 117 | 'operator' => ComparisonOperator::getDynamoDbOperator($operator), |
118 | 118 | 'value' => $value, |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function whereNull($column, $type = "key", $boolean = 'and', $not = false) |
149 | 149 | { |
150 | 150 | $operator = $not ? ComparisonOperator::NOT_NULL : ComparisonOperator::NULL; |
151 | - $this->wheres[] = compact('column', 'operator', 'boolean', 'type'); |
|
151 | + $this->wheres[ ] = compact('column', 'operator', 'boolean', 'type'); |
|
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function value($column) |
228 | 228 | { |
229 | - $result = $this->first([$column])->toArray(); |
|
229 | + $result = $this->first([ $column ])->toArray(); |
|
230 | 230 | return $result !== null ? reset($result) : null; |
231 | 231 | } |
232 | 232 | |
@@ -237,28 +237,28 @@ discard block |
||
237 | 237 | * @param array $columns |
238 | 238 | * @return \Illuminate\Database\Eloquent\Model|object|static|null |
239 | 239 | */ |
240 | - public function first($columns = ['*']) |
|
240 | + public function first($columns = [ '*' ]) |
|
241 | 241 | { |
242 | 242 | return $this->take(1)->all($columns)->first(); |
243 | 243 | } |
244 | 244 | |
245 | - public function get($columns = []) |
|
245 | + public function get($columns = [ ]) |
|
246 | 246 | { |
247 | 247 | $raw = $this->toDynamoDbQuery($columns, 10); |
248 | 248 | if ($raw->op === 'Scan') { |
249 | 249 | $res = $raw->scan($raw->query); |
250 | 250 | } else { |
251 | 251 | $res = $this->client->query($raw->query); |
252 | - $res = $res['Items']; |
|
252 | + $res = $res[ 'Items' ]; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | foreach ($res as $item) { |
256 | - $results[] = (new Marshaler())->unmarshalItem($item); |
|
256 | + $results[ ] = (new Marshaler())->unmarshalItem($item); |
|
257 | 257 | } |
258 | 258 | return $results; |
259 | 259 | } |
260 | 260 | |
261 | - public function query($columns = []) |
|
261 | + public function query($columns = [ ]) |
|
262 | 262 | { |
263 | 263 | $limit = isset($this->limit) ?: -1; |
264 | 264 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param array $columns |
299 | 299 | * @return Collection |
300 | 300 | */ |
301 | - public function all($columns = ['*']): Collection |
|
301 | + public function all($columns = [ '*' ]): Collection |
|
302 | 302 | { |
303 | 303 | $columns = is_array($columns) ? $columns : func_get_args(); |
304 | 304 | $this->columns = $columns; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function finalize() |
39 | 39 | { |
40 | - $this->query = array_filter($this->query, function ($value) { |
|
40 | + $this->query = array_filter($this->query, function($value) { |
|
41 | 41 | return !empty($value) || is_bool($value) || is_numeric($value); |
42 | 42 | }); |
43 | 43 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function offsetExists($offset) |
60 | 60 | { |
61 | - return isset($this->internal()[$offset]); |
|
61 | + return isset($this->internal()[ $offset ]); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function offsetGet($offset) |
74 | 74 | { |
75 | - return $this->internal()[$offset]; |
|
75 | + return $this->internal()[ $offset ]; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function offsetSet($offset, $value) |
91 | 91 | { |
92 | - $this->internal()[$offset] = $value; |
|
92 | + $this->internal()[ $offset ] = $value; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function offsetUnset($offset) |
105 | 105 | { |
106 | - unset($this->internal()[$offset]); |
|
106 | + unset($this->internal()[ $offset ]); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -139,6 +139,6 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function internal() |
141 | 141 | { |
142 | - return [$this->op, $this->query]; |
|
142 | + return [ $this->op, $this->query ]; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | { |
54 | 54 | $operator = strtolower($operator); |
55 | 55 | $mapping = static::getOperatorMapping(); |
56 | - return isset($mapping[$operator]); |
|
56 | + return isset($mapping[ $operator ]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function getDynamoDbOperator($operator) |
60 | 60 | { |
61 | 61 | $mapping = static::getOperatorMapping(); |
62 | 62 | $operator = strtolower($operator); |
63 | - return $mapping[$operator]; |
|
63 | + return $mapping[ $operator ]; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public static function getQuerySupportedOperators($isRangeKey = false) |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | static::BETWEEN, |
77 | 77 | ]; |
78 | 78 | } |
79 | - return [static::EQ]; |
|
79 | + return [ static::EQ ]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | public static function isValidQueryOperator($operator, $isRangeKey = false) |
@@ -93,6 +93,6 @@ discard block |
||
93 | 93 | public static function is($op, $dynamoDbOperator) |
94 | 94 | { |
95 | 95 | $mapping = static::getOperatorMapping(); |
96 | - return $mapping[strtolower($op)] === $dynamoDbOperator; |
|
96 | + return $mapping[ strtolower($op) ] === $dynamoDbOperator; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |