Stack.PHP
A simple and easy to use PHP library for the Stack Exchange API.
Public Member Functions | Protected Attributes | List of all members
PagedRequest Class Reference

A request for a paginated resource. More...

Inheritance diagram for PagedRequest:
BadgeRequest EventRequest InboxItemRequest PostRequest SuggestedEditRequest TagRequest TagSynonymRequest UserRequest

Public Member Functions

 __construct ($url, $return_object, $category=null, $method=null)
 Constructor for a paged request. More...
 
 Exec ()
 Performs the HTTP request. More...
 
 ID ($id)
 Adds the provided ID(s) to the request. More...
 
 Tag ($tag)
 Adds the provided tags to the request. More...
 
 FromDate ($date)
 Ensures that only items created after the specified date are returned in the response. More...
 
 ToDate ($date)
 Ensures that only items created before the specified date are returned in the response. More...
 
 Min ($minimum)
 Sets the minimum value for the range of the current sort. More...
 
 Max ($maximum)
 Sets the maximum value for the range of the current sort. More...
 
 Filter ($filter, $pagination_filter=null)
 Sets the specified filter for the request. More...
 
 URL ()
 Returns the URL constructed from this request. More...
 
 Ascending ()
 Causes the items to be returned in ascending order. More...
 
 Descending ()
 Causes the items to be returned in descending order. More...
 
 InName ($name)
 Returns only the items that contain the specified text in their names. More...
 
 SortBy ($method)
 Sort the results by the provided sort method. More...
 
 SortByActivity ()
 Orders the returned items by activity. More...
 
 SortByCreation ()
 Orders the returned items by creation date. More...
 
 SortByName ()
 Orders the returned items by their name. More...
 
 SortByVotes ()
 Orders the returned items by their score. More...
 

Protected Attributes

 $url
 The URL that will be modified as methods are called.
 

Detailed Description

A request for a paginated resource.

Note: if you used a previous version of Stack.PHP, this class now supersedes the RequestBase class. The separation was due to some API methods returning non-paged responses - but this is no longer the case.

All request classes derive from this class. This class provides the core functionality common to all derived classes, such as initializing the URL class, setting certain common parameters, and issuing requests.

Constructor & Destructor Documentation

◆ __construct()

PagedRequest::__construct (   $url,
  $return_object,
  $category = null,
  $method = null 
)

Constructor for a paged request.

Parameters
$urleither the domain name of the site or a URL object
$return_objectthe type of data expected to be returned
$categorythe category of the requests being made
$methodthe method to invoke

Member Function Documentation

◆ Ascending()

PagedRequest::Ascending ( )

Causes the items to be returned in ascending order.

Returns
the current instance

◆ Descending()

PagedRequest::Descending ( )

Causes the items to be returned in descending order.

Returns
the current instance

◆ Exec()

PagedRequest::Exec ( )

Performs the HTTP request.

Returns
a PagedResponse object that can be used to retrieve the items

◆ Filter()

PagedRequest::Filter (   $filter,
  $pagination_filter = null 
)

Sets the specified filter for the request.

Parameters
$filtera filter ID or a Filter object
$pagination_filtera filter ID or a Filter object
Returns
the current instance

◆ FromDate()

PagedRequest::FromDate (   $date)

Ensures that only items created after the specified date are returned in the response.

Parameters
$datea timestamp representing the minimum date for returned items
Returns
the current instance

◆ ID()

PagedRequest::ID (   $id)

Adds the provided ID(s) to the request.

Parameters
$ideither a single ID or an array of IDs
Returns
the current instance

◆ InName()

PagedRequest::InName (   $name)

Returns only the items that contain the specified text in their names.

Parameters
$namethe name to filter by
Returns
the current instance

◆ Max()

PagedRequest::Max (   $maximum)

Sets the maximum value for the range of the current sort.

Parameters
$maximumthe maximum value
Returns
the current instance

◆ Min()

PagedRequest::Min (   $minimum)

Sets the minimum value for the range of the current sort.

Parameters
$minimumthe minimum value
Returns
the current instance

◆ SortBy()

PagedRequest::SortBy (   $method)

Sort the results by the provided sort method.

Parameters
$methodthe method to sort the results by
Returns
the current instance

Note: there are specific sorting methods available, so use this method only when the desired sort is determined at runtime.

◆ SortByActivity()

PagedRequest::SortByActivity ( )

Orders the returned items by activity.

Returns
the current instance.

◆ SortByCreation()

PagedRequest::SortByCreation ( )

Orders the returned items by creation date.

Returns
the current instance

◆ SortByName()

PagedRequest::SortByName ( )

Orders the returned items by their name.

Returns
the current instance

◆ SortByVotes()

PagedRequest::SortByVotes ( )

Orders the returned items by their score.

Returns
the current instance

◆ Tag()

PagedRequest::Tag (   $tag)

Adds the provided tags to the request.

Parameters
$tageither a single tag or an array of tags
Returns
the current instance

◆ ToDate()

PagedRequest::ToDate (   $date)

Ensures that only items created before the specified date are returned in the response.

Parameters
$datea timestamp representing the maximum date for returned items
Returns
the current instance

◆ URL()

PagedRequest::URL ( )

Returns the URL constructed from this request.

Returns
a string containing the request URL

The documentation for this class was generated from the following file: