Response.php
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
- 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
Properties


string $_tag = null
An optional tag to associate the message with.
null
Details- Type
- string
- Inherited_from
- \PEAR2\Net\RouterOS\Message::$$_tag


array $arguments = array()
An array with message arguments. Keys are the names of the arguments, array values are values for the corresponding argument.
array()
Details- Type
- array
- Inherited_from
- \PEAR2\Net\RouterOS\Message::$$arguments
Methods


__construct(\PEAR2\Net\RouterOS\Communicator $com, bool $asStream = false, \PEAR2\Net\RouterOS\Registry $reg = null) : void
Extracts a new response from a communicator.
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. |
- See
- \PEAR2\Net\RouterOS\getType()
- See
- \PEAR2\Net\RouterOS\getArgument()


__invoke(string $name = null) : string | array
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.
Name | Type | Description |
---|---|---|
$name | string | The name of an argument to get the value of, or NULL to get all arguments as an array. |
Type | Description |
---|---|
string | array | The value of the specified argument, or an array of all arguments if NULL is provided. |


_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.
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. |


getAllArguments() : array
Gets all arguments in an array.
Inherited from: \PEAR2\Net\RouterOS\Message::getAllArguments()Type | Description |
---|---|
array | An array with the keys as argument names, and the array values as argument values. |
- See
- \PEAR2\Net\RouterOS\getArgument()
- See
- \PEAR2\Net\RouterOS\setArgument()


getArgument(string $name) : string | resource
Name | Type | Description |
---|---|---|
$name | string | The name of the argument. |
Type | Description |
---|---|
string | resource | The value of the specified argument. Returns NULL if such an argument is not set. |
- See
- \PEAR2\Net\RouterOS\setArgument()


getTag() : string
Gets the tag that the message is associated with.
Inherited from: \PEAR2\Net\RouterOS\Message::getTag()Type | Description |
---|---|
string | The current tag or NULL if there isn't a tag. |
- See
- \PEAR2\Net\RouterOS\setTag()


getType() : string
Gets the response type.
Type | Description |
---|---|
string | The response type. |
- See
- \PEAR2\Net\RouterOS\setType()


getUnrecognizedWords() : array
Gets a list of unrecognized words.
Type | Description |
---|---|
array | The list of unrecognized words. |


removeAllArguments() : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message
Removes all arguments from the message.
Inherited from: \PEAR2\Net\RouterOS\Message::removeAllArguments()Type | Description |
---|---|
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message | The message object. |


sanitizeArgumentName(mixed $name) : string
Sanitizes a name of an argument (message or query one).
Inherited from: \PEAR2\Net\RouterOS\Message::sanitizeArgumentName()Name | Type | Description |
---|---|---|
$name | mixed | The name to sanitize. |
Type | Description |
---|---|
string | The sanitized name. |


sanitizeArgumentValue(mixed $value) : string
Sanitizes a value of an argument (message or query one).
Inherited from: \PEAR2\Net\RouterOS\Message::sanitizeArgumentValue()Name | Type | Description |
---|---|---|
$value | mixed | The value to sanitize. |
Type | Description |
---|---|
string | The sanitized value. |


setArgument(string $name, string $value = '') : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message
Sets an argument for the message.
Inherited from: \PEAR2\Net\RouterOS\Message::setArgument()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. |
Type | Description |
---|---|
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message | The message object. |
- See
- \PEAR2\Net\RouterOS\getArgument()


setTag(string $tag) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message
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.
Name | Type | Description |
---|---|---|
$tag | string | The tag to set. |
Type | Description |
---|---|
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Message | The message object. |
- See
- \PEAR2\Net\RouterOS\getTag()


setType(string $type) : \PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Response
Sets the response type.
Sets the response type. Valid values are the TYPE_* constants.
Name | Type | Description |
---|---|---|
$type | string | The new response type. |
Type | Description |
---|---|
\PEAR2\Net\RouterOS\self | \PEAR2\Net\RouterOS\Response | The response object. |
- See
- \PEAR2\Net\RouterOS\getType()