Query

A query represents a set of query parameters for a GET request

You should use it to pass query and filter parameters to the Client's get* methods.

For example:

$myQuery = new Query();
$myQuery->set('foo', 'bar');
$myQuery->setPageSize(10);
$myQuery->addFilter(new Filter('field', 'value'));
package

NextEvent\PHPSDK\Util

Methods

__construct

__construct( $partsOrQuery = null) 

Arguments

$partsOrQuery

Sets a query parameter which can be used as a filter.

addFilter(\NextEvent\PHPSDK\Util\Filter $filter) : \NextEvent\PHPSDK\Util\Query

Example:

$query = new Query();
$query->addFilter(new Filter('created', '2018-10-23', '>=')));
Throws
\NextEvent\PHPSDK\Exception\QueryException

If a filter with the same name already exists.

Arguments

Response

\NextEvent\PHPSDK\Util\Query

Clears all parts in this query.

clear() : \NextEvent\PHPSDK\Util\Query

get

get( $name) 

Arguments

$name

Searches for the filter with the given name and returns it.

getFilter(string $name) : \NextEvent\PHPSDK\Util\Filter

Arguments

$name

string

The name of the filter.

Response

\NextEvent\PHPSDK\Util\Filter

The found filter or null if not found.

getPage

getPage() : integer

Response

integer

The page.

getPageSize

getPageSize() : integer

Response

integer

The page size.

Removes the given query parameter.

remove(integer $name) : \NextEvent\PHPSDK\Util\Query

Arguments

$name

integer

The name of the parameter to remove.

Response

\NextEvent\PHPSDK\Util\Query

Removes the previous filter, i.e. removes the given parameter and it's operator.

removeFilter( $nameOrFilter) : \NextEvent\PHPSDK\Util\Query

Arguments

$nameOrFilter

Response

\NextEvent\PHPSDK\Util\Query

Sets a a parameter with it's value.

set(string $name, integer|string|array|boolean $value) : \NextEvent\PHPSDK\Util\Query

Arguments

$name

string

The name of the parameter.

$value

integer|string|array|boolean

The value of the parameter.

Response

\NextEvent\PHPSDK\Util\Query

Sets the page for this query.

setPage(integer $value) : \NextEvent\PHPSDK\Util\Query

Helper function which can be used to set a specific page when fetching a collection of models.

Throws
\NextEvent\PHPSDK\Exception\QueryException

If the page is not an integer or not positive.

Arguments

$value

integer

The page.

Response

\NextEvent\PHPSDK\Util\Query

Sets the page size for this query.

setPageSize(integer $value) : \NextEvent\PHPSDK\Util\Query

Helper function which can be used to set a page size when fetching a collection of models.

Throws
\NextEvent\PHPSDK\Exception\QueryException

If the page size is not an integer or not positive.

Arguments

$value

integer

The page size.

Response

\NextEvent\PHPSDK\Util\Query

toArray

toArray() : array

Response

array

The parts of this query.

Converts the given array or query to a string, which can be used for a GET request.

toString(array|\NextEvent\PHPSDK\Util\Query $arrayOrQuery = null) : string
static

For example array('myId' => array(1,2), 'myHash' => 'abc') becomes myId=1,2&myHash=abc.

Arguments

$arrayOrQuery

array|\NextEvent\PHPSDK\Util\Query

A query instance or a list of query parameters. Array values will be converted into a ',' separated string.

Response

string

An url encoded string.