@@ -21,6 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | 23 | * @param string ...$fields |
| 24 | + * @param string[] $fields |
|
| 24 | 25 | * @return object[]|iterable |
| 25 | 26 | */ |
| 26 | 27 | public function get(string ...$fields): iterable |
@@ -167,6 +168,7 @@ discard block |
||
| 167 | 168 | |
| 168 | 169 | /** |
| 169 | 170 | * @param string ...$fields |
| 171 | + * @param string[] $fields |
|
| 170 | 172 | * @return Collection |
| 171 | 173 | */ |
| 172 | 174 | public function collect(string ...$fields): Collection |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $processor = $this->getRepository()->getProcessor(); |
| 29 | 29 | |
| 30 | 30 | if (\count($fields)) { |
| 31 | - return \collect($processor->getArrayResult($this))->map(function (array $data) use ($fields) { |
|
| 31 | + return \collect($processor->getArrayResult($this))->map(function(array $data) use ($fields) { |
|
| 32 | 32 | if (isset($data[0]) && \is_array($data[0])) { |
| 33 | 33 | $data = $data[0]; |
| 34 | 34 | } |
@@ -89,22 +89,22 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | switch ($typeOf) { |
| 91 | 91 | case 'callable': |
| 92 | - return function (callable $applicator = null) use ($result) { |
|
| 92 | + return function(callable $applicator = null) use ($result) { |
|
| 93 | 93 | return ($applicator ?? '\\value')($result); |
| 94 | 94 | }; |
| 95 | 95 | |
| 96 | 96 | case 'object': |
| 97 | - return (object)$result; |
|
| 97 | + return (object) $result; |
|
| 98 | 98 | |
| 99 | 99 | case 'array': |
| 100 | 100 | case 'iterable': |
| 101 | - return (array)$result; |
|
| 101 | + return (array) $result; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $function = $typeOf . 'val'; |
|
| 104 | + $function = $typeOf.'val'; |
|
| 105 | 105 | |
| 106 | - if (! \function_exists($function)) { |
|
| 107 | - throw new \InvalidArgumentException('Could not cast to type ' . $typeOf); |
|
| 106 | + if (!\function_exists($function)) { |
|
| 107 | + throw new \InvalidArgumentException('Could not cast to type '.$typeOf); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return $function($result); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function count(?string $field = 'id'): int |
| 119 | 119 | { |
| 120 | - return $this->select('COUNT(' . $field . ') AS __count') |
|
| 120 | + return $this->select('COUNT('.$field.') AS __count') |
|
| 121 | 121 | ->scalar('__count', 'int'); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function sum(string $field = null): int |
| 130 | 130 | { |
| 131 | - return $this->select('SUM(' . $field . ') AS __sum') |
|
| 131 | + return $this->select('SUM('.$field.') AS __sum') |
|
| 132 | 132 | ->scalar('__sum', 'int'); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function avg(string $field = null): int |
| 141 | 141 | { |
| 142 | - return $this->select('AVG(' . $field . ') AS __avg') |
|
| 142 | + return $this->select('AVG('.$field.') AS __avg') |
|
| 143 | 143 | ->scalar('__avg', 'int'); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function max(string $field = null): int |
| 152 | 152 | { |
| 153 | - return $this->select('MAX(' . $field . ') AS __max') |
|
| 153 | + return $this->select('MAX('.$field.') AS __max') |
|
| 154 | 154 | ->scalar('__max', 'int'); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function min(string $field = null): int |
| 163 | 163 | { |
| 164 | - return $this->select('MIN(' . $field . ') AS __min') |
|
| 164 | + return $this->select('MIN('.$field.') AS __min') |
|
| 165 | 165 | ->scalar('__min', 'int'); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -58,6 +58,6 @@ |
||
| 58 | 58 | { |
| 59 | 59 | $alias = $sqlWalker->getSQLTableAlias($this->table->value, $this->alias->value); |
| 60 | 60 | |
| 61 | - return $alias . '.' . $this->field->value; |
|
| 61 | + return $alias.'.'.$this->field->value; |
|
| 62 | 62 | } |
| 63 | 63 | } |
@@ -72,16 +72,16 @@ |
||
| 72 | 72 | \preg_match('/^([\w\.\:\*]+)[\w\.\:\*\s]*?$/iu', $query, $m); |
| 73 | 73 | if (\count($m)) { |
| 74 | 74 | $wrapper = [\str_replace_first($m[1], '%s', $m[0])]; |
| 75 | - return \array_merge($wrapper, $this->analyzePrefix((string)$m[1])); |
|
| 75 | + return \array_merge($wrapper, $this->analyzePrefix((string) $m[1])); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | \preg_match('/^.+?\(([\w\.\:\*]+).*?$/isu', $query, $m); |
| 79 | 79 | if (\count($m)) { |
| 80 | 80 | $wrapper = [\str_replace_first($m[1], '%s', $m[0])]; |
| 81 | - return \array_merge($wrapper, $this->analyzePrefix((string)$m[1])); |
|
| 81 | + return \array_merge($wrapper, $this->analyzePrefix((string) $m[1])); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - return ['%s', (string)$query, false]; |
|
| 84 | + return ['%s', (string) $query, false]; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | private function extract(iterable $result): \Generator |
| 71 | 71 | { |
| 72 | 72 | foreach ($result as $item) { |
| 73 | - if (isset($item[0]) && ! \is_scalar($item[0])) { |
|
| 73 | + if (isset($item[0]) && !\is_scalar($item[0])) { |
|
| 74 | 74 | $entity = \array_shift($item); |
| 75 | 75 | yield $entity => $item; |
| 76 | 76 | } else { |