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

Represents a filter for data returned in the response. More...

Public Member Functions

 __construct ($filter_id=null)
 Constructor for a Filter object. More...
 
 GetID ()
 Returns an ID for the filter, retrieving one if it does not exist. More...
 
 SetID ($filter_id)
 Sets the filter ID. More...
 
 GetIncludeItems ()
 Retrieves the items that are to be included in the filter. More...
 
 SetIncludeItems ($items)
 Includes the specified items in the filter. More...
 
 SetExcludeItems ($items)
 Excludes the specified items from the filter. More...
 
 GetUnsafe ()
 Returns whether this filter should return HTML-safe content. More...
 
 SetUnsafe ($unsafe=TRUE)
 Indicates whether the responses returned should be HTML-safe. More...
 

Static Public Attributes

static $default_filter = 'default'
 The filter used by default when pagination data is not needed.
 
static $default_pagination_filter = '!DnBO_'
 The filter used by default when pagination data is required.
 

Detailed Description

Represents a filter for data returned in the response.

A filter allows you to decide what content is provided in the response that the API returns. You can choose specific data that you would like returned and specific data you would like omitted.

By default, Stack.PHP uses a filter that is similar to the default filter with the addition of the remaining .wrapper properties. Stack.PHP may run into trouble stepping through paged data if you enable a filter that does not provide this data - however, if you do not need paged data, you may see a speed increase by omitting this data.

You can change the default filter by setting API::$filter.

Constructor & Destructor Documentation

◆ __construct()

Filter::__construct (   $filter_id = null)

Constructor for a Filter object.

Parameters
$filter_idthe ID of an existing filter

Member Function Documentation

◆ GetID()

Filter::GetID ( )

Returns an ID for the filter, retrieving one if it does not exist.

Returns
the ID for the filter

◆ GetIncludeItems()

Filter::GetIncludeItems ( )

Retrieves the items that are to be included in the filter.

Returns
an array of items to be included

◆ GetUnsafe()

Filter::GetUnsafe ( )

Returns whether this filter should return HTML-safe content.

Returns
TRUE if this filter returns unsafe data

◆ SetExcludeItems()

Filter::SetExcludeItems (   $items)

Excludes the specified items from the filter.

Parameters
$itemseither a single item or an array of items
Returns
the current instance

Note: if this filter already possesses an ID, it will be discarded because it will no longer be valid after the new items are added.

◆ SetID()

Filter::SetID (   $filter_id)

Sets the filter ID.

Parameters
$filter_idthe ID of the filter
Returns
the current instance

Note: if this filter already possesses an ID, its stored data will be discarded since it will not be valid for the current filter.

◆ SetIncludeItems()

Filter::SetIncludeItems (   $items)

Includes the specified items in the filter.

Parameters
$itemseither a single item or an array of items
Returns
the current instance

Note: if this filter already possesses an ID, it will be discarded because it will no longer be valid after the new items are added.

◆ SetUnsafe()

Filter::SetUnsafe (   $unsafe = TRUE)

Indicates whether the responses returned should be HTML-safe.

Parameters
$unsafeTRUE to return unsafe responses
Returns
the current instance

Note: if this filter already possesses an ID, it will be discarded because it will no longer be valid after this parameter is set.


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