@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | |
10 | -class Table{ |
|
10 | +class Table { |
|
11 | 11 | public function getuser() |
12 | 12 | { |
13 | 13 | return "ok"; |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | echo "class find\r\n"; |
21 | 21 | |
22 | 22 | $t1 = microtime(true); |
23 | - foreach (range(1,500) as $a){ |
|
23 | + foreach (range(1, 500) as $a) { |
|
24 | 24 | $func = "get".$field; |
25 | - if (method_exists($this,$func)) { |
|
26 | - call_user_func([$this,$func]); |
|
25 | + if (method_exists($this, $func)) { |
|
26 | + call_user_func([ $this, $func ]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | - var_dump(microtime(true)-$t1); |
|
30 | + var_dump(microtime(true) - $t1); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | 34 | echo "array find\r\n"; |
35 | 35 | $t1 = microtime(true); |
36 | - foreach (range(1,500) as $a) { |
|
37 | - $a = ['set.user' => 'getuser', 'get.user' => 'getuser']; |
|
38 | - $func = 'set.' . $field; |
|
36 | + foreach (range(1, 500) as $a) { |
|
37 | + $a = [ 'set.user' => 'getuser', 'get.user' => 'getuser' ]; |
|
38 | + $func = 'set.'.$field; |
|
39 | 39 | // if (isset($a[$func])) { |
40 | - call_user_func([$this, $a[$func]]); |
|
40 | + call_user_func([ $this, $a[ $func ] ]); |
|
41 | 41 | // } |
42 | 42 | } |
43 | - var_dump(microtime(true)-$t1); |
|
43 | + var_dump(microtime(true) - $t1); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | $item = $marshaler->marshalJson(' |
30 | 30 | { |
31 | - "year": ' . $year . ', |
|
32 | - "title": "' . $title . '", |
|
31 | + "year": ' . $year.', |
|
32 | + "title": "' . $title.'", |
|
33 | 33 | "info": { |
34 | 34 | "plot": "Nothing happens at all.", |
35 | 35 | "rating": 0 |
@@ -52,5 +52,5 @@ discard block |
||
52 | 52 | |
53 | 53 | } catch (DynamoDbException $e) { |
54 | 54 | echo "Unable to add item:\n"; |
55 | - echo $e->getMessage() . "\n"; |
|
55 | + echo $e->getMessage()."\n"; |
|
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class DB |
8 | 8 | { |
9 | - public static $config = []; |
|
9 | + public static $config = [ ]; |
|
10 | 10 | public static $connect; |
11 | 11 | |
12 | 12 | public static function config(array $config, string $connect = 'default') |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - public $query = []; |
|
56 | - public $batchWriteItem = []; |
|
55 | + public $query = [ ]; |
|
56 | + public $batchWriteItem = [ ]; |
|
57 | 57 | |
58 | 58 | /** @var $dynamodbClient DynamoDbClient */ |
59 | 59 | protected $dynamodbClient; |
60 | 60 | |
61 | 61 | public function __construct(array $config) |
62 | 62 | { |
63 | - $this->dynamodbClient = new DynamoDbClient($config["S3Config"]); |
|
63 | + $this->dynamodbClient = new DynamoDbClient($config[ "S3Config" ]); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function hydrate(array $query) |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | |
72 | 72 | public function setExpressionAttributeName($placeholder, $name) |
73 | 73 | { |
74 | - $this->query['ExpressionAttributeNames'][$placeholder] = $name; |
|
74 | + $this->query[ 'ExpressionAttributeNames' ][ $placeholder ] = $name; |
|
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 | |
78 | 78 | public function setExpressionAttributeValue($placeholder, $value) |
79 | 79 | { |
80 | - $this->query['ExpressionAttributeValues'][$placeholder] = $value; |
|
80 | + $this->query[ 'ExpressionAttributeValues' ][ $placeholder ] = $value; |
|
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | 84 | public function setKeyConditionExpression($mapping) |
85 | 85 | { |
86 | 86 | if ($mapping) { |
87 | - $this->query['KeyConditionExpression'] = $mapping; |
|
87 | + $this->query[ 'KeyConditionExpression' ] = $mapping; |
|
88 | 88 | } |
89 | 89 | return $this; |
90 | 90 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function setProjectionExpression($expression) |
93 | 93 | { |
94 | 94 | if ($expression) { |
95 | - $this->query['ProjectionExpression'] = $expression; |
|
95 | + $this->query[ 'ProjectionExpression' ] = $expression; |
|
96 | 96 | } |
97 | 97 | return $this; |
98 | 98 | } |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | public function setExpressionAttributeValues($mapping) |
101 | 101 | { |
102 | 102 | if ($mapping) { |
103 | - $this->query['ExpressionAttributeValues'] = $mapping; |
|
103 | + $this->query[ 'ExpressionAttributeValues' ] = $mapping; |
|
104 | 104 | } |
105 | 105 | return $this; |
106 | 106 | } |
107 | 107 | |
108 | 108 | public function setRequestItems($items) |
109 | 109 | { |
110 | - $this->batchWriteItem['RequestItems'] = $items; |
|
110 | + $this->batchWriteItem[ 'RequestItems' ] = $items; |
|
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | public function __call($method, $parameters) |
137 | 137 | { |
138 | 138 | if (strpos($method, 'set') === 0) { |
139 | - $key = array_reverse(explode('set', $method, 2))[0]; |
|
140 | - $this->query[$key] = current($parameters); |
|
139 | + $key = array_reverse(explode('set', $method, 2))[ 0 ]; |
|
140 | + $this->query[ $key ] = current($parameters); |
|
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | throw new BadMethodCallException(sprintf( |
@@ -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 | ] |