Skip to content

Commit

Permalink
docs(add-paging-to-result-set): improved PHPDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
ncosta-ic committed Apr 12, 2024
1 parent 5f4ee88 commit fb6b09c
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ResultSet implements Iterator
protected $pageSize;

/**
* Construct the {@see self::class class} object
*
* @param Traversable $traversable
* @param ?int $limit
* @param ?int $offset
Expand All @@ -48,10 +50,13 @@ public function __construct(Traversable $traversable, $limit = null, $offset = n
}

/**
* Returns the current page calculated from the {@see ResultSet::$offset} and the {@see ResultSet::$pageSize}
* Get the current page number
*
* Returns the current page, calculated by the {@see self::$position position}, {@see self::$offset offset}
* and the {@see self::$pageSize page size}
*
* @return int
* @throws BadMethodCallException if no {@see ResultSet::$pageSize} has been provided
* @return int page
* @throws BadMethodCallException if no {@see self::$pageSize page size} has been provided
*/
public function getCurrentPage(): int
{
Expand All @@ -65,13 +70,13 @@ public function getCurrentPage(): int
return 1;
}

throw new BadMethodCallException(`The 'pageSize' property has not been set. Cannot calculate pages.`);
throw new BadMethodCallException("The 'pageSize' property has not been set. Cannot calculate pages.");
}

/**
* Sets the amount of items a page should contain (needed for pagination)
* Set the amount of entries a page should contain (needed for pagination)
*
* @param ?int $size
* @param ?int $size entries per page
* @return $this
*/
public function setPageSize(?int $size)
Expand All @@ -82,7 +87,7 @@ public function setPageSize(?int $size)
}

/**
* Create a new result set from the given query
* Create a new result set from the given {@see Query query}
*
* @param Query $query
*
Expand All @@ -96,7 +101,7 @@ public static function fromQuery(Query $query)
/**
* Do not cache query result
*
* ResultSet instance can only be iterated once
* {@see self::class class} instance can only be iterated once
*
* @return $this
*/
Expand All @@ -108,6 +113,8 @@ public function disableCache()
}

/**
* Check if dataset has more entries
*
* @return bool
*/
public function hasMore()
Expand All @@ -116,6 +123,8 @@ public function hasMore()
}

/**
* Check if dataset has a result
*
* @return bool
*/
public function hasResult()
Expand Down Expand Up @@ -199,6 +208,8 @@ protected function advance()
}

/**
* Yield entry from dataset
*
* @param Traversable $traversable
* @return Generator
*/
Expand Down

0 comments on commit fb6b09c

Please sign in to comment.