Response.php

Show: inherited
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.0b3  

\PEAR2\Net\RouterOS\Response

Package: PEAR2\Net\RouterOS
Represents a RouterOS response.
Parent(s)
\PEAR2\Net\RouterOS\Message
Author
Vasil Rangelov  
Category
Net  
License
LGPL License 2.1  
Link
http://pear2.php.net/PEAR2_Net_RouterOS  

Constants

Constant  TYPE_FINAL = '!done'
The last response for a request.
Constant  TYPE_DATA = '!re'
A response with data.
Constant  TYPE_ERROR = '!trap'
A response signifying error.
Constant  TYPE_FATAL = '!fatal'
A response signifying a fatal error, due to which the connection would be terminated.

Properties

Propertyprivatestring $_tag = null
inherited

An optional tag to associate the message with.

Inherited from: \PEAR2\Net\RouterOS\Message::$$_tag
Default valuenullDetails
Type
string
Inherited_from
\PEAR2\Net\RouterOS\Message::$$_tag  
Propertyprivatestring $_type

The response type.

Details
Type
string
Propertyprotectedarray $arguments = array()
inherited

An array with message arguments. Keys are the names of the arguments, array values are values for the corresponding argument.

Inherited from: \PEAR2\Net\RouterOS\Message::$$arguments
Default valuearray()Details
Type
array
Inherited_from
\PEAR2\Net\RouterOS\Message::$$arguments  
Propertyprotectedarray $unrecognizedWords = array()

An array of unrecognized words in network order.

Default valuearray()Details
Type
array

Methods

methodpublic__construct(\PEAR2\Net\RouterOS\Communicator $com, bool $asStream = false, \PEAR2\Net\RouterOS\Registry $reg = null) : void

Extracts a new response from a communicator.

Parameters
Name Type Description
$com \PEAR2\Net\RouterOS\Communicator

The communicator from which to extract the new response.

$asStream bool

Whether to populate the argument values with streams instead of strings.

$reg \PEAR2\Net\RouterOS\Registry

An optional registry to sync the response with.

Details
See
\PEAR2\Net\RouterOS\getType()  
See
\PEAR2\Net\RouterOS\getArgument()  
methodpublic__invoke(string $name = null) : string | array
inherited

A shorthand gateway.

Inherited from: \PEAR2\Net\RouterOS\Message::__invoke()

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
Name Type Description
$name string

The name of an argument to get the value of, or NULL to get all arguments as an array.

Returns
Type Description
string | array The value of the specified argument, or an array of all arguments if NULL is provided.
methodprivate_receive(\PEAR2\Net\RouterOS\Communicator $com, bool $asStream = false) : void

Extracts a new response from a communicator.

This is the function that performs the actual receiving, while the constructor is also involved in locks and registry sync.

Parameters
Name Type Description
$com \PEAR2\Net\RouterOS\Communicator

The communicator from which to extract the new response.

$asStream bool

Whether to populate the argument values with streams instead of strings.

methodpublicgetAllArguments() : array
inherited

Gets all arguments in an array.

Inherited from: \PEAR2\Net\RouterOS\Message::getAllArguments()
Returns
Type Description
array An array with the keys as argument names, and the array values as argument values.
Details
See
\PEAR2\Net\RouterOS\getArgument()  
See
\PEAR2\Net\RouterOS\setArgument()  
methodpublicgetArgument(string $name) : string | resource
inherited

Gets the value of an argument.

Inherited from: \PEAR2\Net\RouterOS\Message::getArgument()
Parameters
Name Type Description
$name string

The name of the argument.

Returns
Type Description
string | resource The value of the specified argument. Returns NULL if such an argument is not set.
Details
See
\PEAR2\Net\RouterOS\setArgument()  
methodpublicgetTag() : string
inherited

Gets the tag that the message is associated with.

Inherited from: \PEAR2\Net\RouterOS\Message::getTag()
Returns
Type Description
string The current tag or NULL if there isn't a tag.
Details
See
\PEAR2\Net\RouterOS\setTag()  
methodpublicgetType() : string

Gets the response type.

Returns
Type Description
string The response type.
Details
See
\PEAR2\Net\RouterOS\setType()  
methodpublicgetUnrecognizedWords() : array

Gets a list of unrecognized words.

Returns
Type Description
array The list of unrecognized words.
methodprotectedremoveAllArguments() : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message
inherited

Removes all arguments from the message.

Inherited from: \PEAR2\Net\RouterOS\Message::removeAllArguments()
Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message The message object.
methodpublicsanitizeArgumentName(mixed $name) : string
staticinherited

Sanitizes a name of an argument (message or query one).

Inherited from: \PEAR2\Net\RouterOS\Message::sanitizeArgumentName()
Parameters
Name Type Description
$name mixed

The name to sanitize.

Returns
Type Description
string The sanitized name.
methodpublicsanitizeArgumentValue(mixed $value) : string
staticinherited

Sanitizes a value of an argument (message or query one).

Inherited from: \PEAR2\Net\RouterOS\Message::sanitizeArgumentValue()
Parameters
Name Type Description
$value mixed

The value to sanitize.

Returns
Type Description
string The sanitized value.
methodprotectedsetArgument(string $name, string $value = '') : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message
inherited

Sets an argument for the message.

Inherited from: \PEAR2\Net\RouterOS\Message::setArgument()
Parameters
Name Type Description
$name string

Name of the argument.

$value string

Value of the argument. Setting the value to NULL removes an argument of this name.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message The message object.
Details
See
\PEAR2\Net\RouterOS\getArgument()  
methodprotectedsetTag(string $tag) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message
inherited

Sets the tag to associate the request with.

Inherited from: \PEAR2\Net\RouterOS\Message::setTag()

Sets the tag to associate the message with. Setting NULL erases the currently set tag.

Parameters
Name Type Description
$tag string

The tag to set.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message The message object.
Details
See
\PEAR2\Net\RouterOS\getTag()  
methodprotectedsetType(string $type) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Response

Sets the response type.

Sets the response type. Valid values are the TYPE_* constants.

Parameters
Name Type Description
$type string

The new response type.

Returns
Type Description
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Response The response object.
Details
See
\PEAR2\Net\RouterOS\getType()  
Documentation was generated by phpDocumentor 2.0.0a8.