ResponseCollection.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
RouterOS API client implementation.
RouterOS is the flag product of the company MikroTik and is a powerful router software. One of its many abilities is to allow control over it via an API. This package provides a client for that API, in turn allowing you to use PHP to control RouterOS hosts. PHP version 5
Author
Vasil Rangelov  
Category
Net  
Copyright
2011 Vasil Rangelov  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  
Package
PEAR2_Net_RouterOS  
Version
1.0.0b4  

\PEAR2\Net\RouterOS\ResponseCollection

Package: PEAR2_Net_RouterOS
Represents a collection of RouterOS responses.
Implements
Author
Vasil Rangelov  
Category
Net  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  

Properties

>VPropertyprotectedarray $argumentMap = null

An array with all distinct arguments across all {@link Response} objects. Created at the first call of {@link getArgumentMap()}.

Default valuenullDetails
Type
array
>VPropertyprotectedint $position = 0

A pointer, as required by SeekableIterator.

Default value0Details
Type
int
>VPropertyprotectedarray $responseTags = array()

An array with each {@link Response} object's tag.

Default valuearray()Details
Type
array
>VPropertyprotectedarray $responseTypes = array()

An array with each {@link Response} object's type.

Default valuearray()Details
Type
array
>VPropertyprotectedarray $responses = array()

An array with all {@link Response} objects.

Default valuearray()Details
Type
array

Methods

methodpublic__call(string $method, array $args) : mixed

Calls a method of the response pointed by the pointer.

Calls a method of the response pointed by the pointer. This is a magic PHP method, thanks to which any function you call on the collection that is not defined will be redirected to the response.
Parameters
NameTypeDescription
$methodstring

The name of the method to call.

$argsarray

The arguments to pass to the method.

Returns
TypeDescription
mixedWhatever the called function returns.
methodpublic__construct(array $responses) : void

Creates a new collection.

Parameters
NameTypeDescription
$responsesarray

An array of responses, in network order.

methodpublic__invoke(int $offset = null) : \PEAR2\Net\RouterOS\Response

A shorthand gateway.

This is a magic PHP method that allows you to call the object as a function. Depending on the argument given, one of the other functions in the class is invoked and its returned value is returned by this function.
Parameters
NameTypeDescription
$offsetint

The offset of the response to seek to. Setting NULL will seek to the last response.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe {@link Response} at the specified index, last reponse if no index is provided or FALSE if the index is invalid or the collection is empty.
methodpubliccount() : int

Counts the responses in the collection.

Returns
TypeDescription
intThe number of responses in the collection.
methodpubliccurrent() : \PEAR2\Net\RouterOS\Response

Gets the response at the current pointer position.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe response at the current pointer position, or FALSE if the position is not valid.
methodpublicend() : \PEAR2\Net\RouterOS\Response

Moves the pointer to the last valid position, and returns the last response.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe last response in the collection, or FALSE if the collection is empty.
methodpublicgetAllOfType(string $type) : \PEAR2\Net\RouterOS\ResponseCollection

Gets all responses of a specified type.

Parameters
NameTypeDescription
$typestring

The response type to filter by. Valid values are the Response::TYPE_* constants.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseCollectionA new collection with responses of the specified type.
methodpublicgetAllTagged(string $tag) : \PEAR2\Net\RouterOS\ResponseCollection

Gets all responses with a specified tag.

Parameters
NameTypeDescription
$tagstring

The tag to filter by.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseCollectionA new collection with responses having the specified tag.
methodpublicgetArgumentMap() : array

Gets all distinct argument names.

Gets all distinct argument names across all responses.
Returns
TypeDescription
arrayAn array with all distinct argument names as keys, and the indexes at which they occur as values.
methodpublicgetLast() : \PEAR2\Net\RouterOS\Response

Gets the last {@link Response} in the collection.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe last response in the collection or FALSE if the collection is empty.
methodpublickey() : int

Gets the key at the current pointer position.

Returns
TypeDescription
intThe key at the current pointer position, i.e. the pointer position itself, or FALSE if the position is not valid.
methodpublicnext() : \PEAR2\Net\RouterOS\Response

Moves the pointer forward by 1, and gets the next response.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe next {@link Response} object, or FALSE if the position is not valid.
methodpublicoffsetExists(int $offset) : bool

Checks if an offset exists.

Parameters
NameTypeDescription
$offsetint

The offset to check.

Returns
TypeDescription
boolTRUE if the offset exists, FALSE otherwise.
methodpublicoffsetGet(int $offset) : \PEAR2\Net\RouterOS\Response

Gets a {@link Response} from a specified offset.

Parameters
NameTypeDescription
$offsetint

The offset of the desired response.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe response at the specified offset.
methodpublicoffsetSet(int $offset, \PEAR2\Net\RouterOS\Response $value) : void

N/A

This method exists only because it is required for ArrayAccess. The collection is read only.
Parameters
NameTypeDescription
$offsetint

N/A

$value\PEAR2\Net\RouterOS\Response

N/A

methodpublicoffsetUnset(int $offset) : void

N/A

This method exists only because it is required for ArrayAccess. The collection is read only.
Parameters
NameTypeDescription
$offsetint

N/A

methodpublicprev() : \PEAR2\Net\RouterOS\Response

Moves the pointer backwards by 1, and gets the previous response.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe next {@link Response} object, or FALSE if the position is not valid.
methodpublicrewind() : \PEAR2\Net\RouterOS\Response

Resets the pointer to 0, and returns the first response.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe first response in the collection, or FALSE if the collection is empty.
methodpublicseek(int $position) : \PEAR2\Net\RouterOS\Response

Moves the position pointer to a specified position.

Parameters
NameTypeDescription
$positionint

The position to move to.

Returns
TypeDescription
\PEAR2\Net\RouterOS\ResponseThe {@link Response} at the specified position, or FALSE if the specified position is not valid.
methodpublictoArray() : array

Gets the whole collection as an array.

Returns
TypeDescription
arrayAn array with all responses, in network order.
methodpublicvalid() : bool

Checks if the pointer is still pointing to an existing offset.

Returns
TypeDescription
boolTRUE if the pointer is valid, FALSE otherwise.
Documentation was generated by phpDocumentor 2.1.0-DEV .