Documentation

SearchResult
in package

Table of Contents

Properties

$count  : int
$perPage  : int
$results  : array<string|int, mixed>
$searchTerm  : string

Methods

__construct()  : mixed
Constructor for SearchResult.
getPagesCount()  : int
Calculates and returns the total number of pages available based on the number of results and results per page.
getResults()  : array<string|int, mixed>
Retrieves the search results for the given page.
getResultsCount()  : int
Returns the total number of results found by the search query.
performSearch()  : array<string|int, mixed>
Performs a search query for the specified page.

Properties

Methods

__construct()

Constructor for SearchResult.

public __construct(string $searchTerm, int $page[, int $perPage = 20 ]) : mixed

Initializes the search term and perPage, then performs a search for the first page.

Parameters
$searchTerm : string

The search query term.

$page : int
$perPage : int = 20

Optional, the number of results per page. Defaults to 20.

getPagesCount()

Calculates and returns the total number of pages available based on the number of results and results per page.

public getPagesCount() : int
Return values
int

The total number of pages.

getResults()

Retrieves the search results for the given page.

public getResults() : array<string|int, mixed>
Return values
array<string|int, mixed>

The search results for the requested page.

getResultsCount()

Returns the total number of results found by the search query.

public getResultsCount() : int
Return values
int

The total number of results.

performSearch()

Performs a search query for the specified page.

private performSearch(int $page) : array<string|int, mixed>
Parameters
$page : int

The page number to fetch.

Return values
array<string|int, mixed>

The search results for the requested page.


        
On this page

Search results