Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion src/Annotation/DbQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@

use Attribute;

/**
* Runs the SQL file of the ID with the method arguments and returns the result
*
* @see https://bearsunday.github.io/manuals/1.0/en/database_media.html#dbquery
* @see \Ray\MediaQuery\DbQueryInterceptor
*/
#[Attribute(Attribute::TARGET_METHOD)]
final class DbQuery
{
/** @param 'row'|'row_list' $type */
/**
* @param string $id SQL file name in the SQL directory, without `.sql`
* @param 'row'|'row_list' $type `row` returns a single row for an `array` return type
* @param string $factory Class whose factory method creates each row
*/
public function __construct(
public string $id,
public string $type = 'row_list',
Expand Down
10 changes: 9 additions & 1 deletion src/Annotation/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@

use Attribute;

/**
* Paginates the #[DbQuery] result into a lazily queried PagesInterface
*
* @see https://bearsunday.github.io/manuals/1.0/en/database_media.html#pagination
*/
#[Attribute(Attribute::TARGET_METHOD)]
final class Pager
{
/** @param int|string $perPage int:the number of items, string: the name of the argument of the number of items */
/**
* @param int|string $perPage int:the number of items, string: the name of the argument of the number of items
* @param string $template URI template of the page links in the pager HTML
*/
public function __construct(
public int|string $perPage = 10,
public string $template = '/{?page}',
Expand Down
3 changes: 3 additions & 0 deletions src/Annotation/Qualifier/FactoryMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Attribute;
use Ray\Di\Di\Qualifier;

/**
* Qualifies the name of the method called on the `factory` class of #[DbQuery]
*/
#[Attribute(Attribute::TARGET_PARAMETER)]
#[Qualifier]
final class FactoryMethod
Expand Down
3 changes: 3 additions & 0 deletions src/Annotation/Qualifier/SqlDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Attribute;
use Ray\Di\Di\Qualifier;

/**
* Qualifies the path of the directory that holds the SQL files
*/
#[Attribute(Attribute::TARGET_PARAMETER)]
#[Qualifier]
final class SqlDir
Expand Down
Loading