Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/Query/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ public function limit(?int $limit = null): self
return $this;
}

/**
* @return int<0, max>|null
*/
public function getLimit(): ?int
{
return $this->limit;
Expand All @@ -271,6 +274,9 @@ public function offset(?int $offset = null): self
return $this;
}

/**
* @return int<0, max>|null
*/
public function getOffset(): ?int
{
return $this->offset;
Expand All @@ -294,6 +300,8 @@ public function run(): StatementInterface
*
* You must return FALSE from walk function to stop chunking.
*
* @param int<1, max> $limit Chunk size.
*
* @throws \Throwable
*/
public function runChunks(int $limit, callable $callback): void
Expand Down Expand Up @@ -324,7 +332,9 @@ public function runChunks(int $limit, callable $callback): void
/**
* Count number of rows in query. Limit, offset, order by, group by values will be ignored.
*
* @psalm-param non-empty-string $column Column to count by (every column by default).
* @param non-empty-string $column Column to count by (every column by default).
*
* @return int<0, max>
*/
public function count(string $column = '*', bool $distinct = false): int
{
Expand All @@ -346,31 +356,31 @@ public function count(string $column = '*', bool $distinct = false): int
}

/**
* @psalm-param non-empty-string $column
* @param non-empty-string $column
*/
public function avg(string $column): mixed
{
return $this->runAggregate('AVG', $column);
}

/**
* @psalm-param non-empty-string $column
* @param non-empty-string $column
*/
public function max(string $column): mixed
{
return $this->runAggregate('MAX', $column);
}

/**
* @psalm-param non-empty-string $column
* @param non-empty-string $column
*/
public function min(string $column): mixed
{
return $this->runAggregate('MIN', $column);
}

/**
* @psalm-param non-empty-string $column
* @param non-empty-string $column
*/
public function sum(string $column): mixed
{
Expand Down Expand Up @@ -436,8 +446,8 @@ private function addOrder(string|FragmentInterface $field, ?string $order): self
}

/**
* @psalm-param non-empty-string $method
* @psalm-param non-empty-string $column
* @param non-empty-string $method
* @param non-empty-string $column
*/
private function runAggregate(string $method, string $column): mixed
{
Expand Down
Loading