forked from kevinowino869/mitrobill
update PEAR
This commit is contained in:
@ -2,17 +2,18 @@
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2011 Vasil Rangelov
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version 1.0.0b5
|
||||
* @version 1.0.0b6
|
||||
* @link http://pear2.php.net/PEAR2_Net_RouterOS
|
||||
*/
|
||||
/**
|
||||
@ -31,13 +32,13 @@ use Countable;
|
||||
use IteratorAggregate;
|
||||
|
||||
/**
|
||||
* Requred for IteratorAggregate::getIterator() to work properly with foreach.
|
||||
* Required for IteratorAggregate::getIterator() to work properly with foreach.
|
||||
*/
|
||||
use ArrayObject;
|
||||
|
||||
/**
|
||||
* Represents a RouterOS message.
|
||||
*
|
||||
*
|
||||
* @category Net
|
||||
* @package PEAR2_Net_RouterOS
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
@ -48,27 +49,32 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array An array with message attributes. Each array key is the the
|
||||
* name of an attribute, and the correspding array value is the value
|
||||
* for that attribute.
|
||||
* An array with message attributes.
|
||||
*
|
||||
* Each array key is the the name of an attribute,
|
||||
* and the corresponding array value is the value for that attribute.
|
||||
*
|
||||
* @var array<string,string|resource>
|
||||
*/
|
||||
protected $attributes = array();
|
||||
|
||||
/**
|
||||
* @var string An optional tag to associate the message with.
|
||||
* An optional tag to associate the message with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tag = null;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $name The name of an attribute to get the value of, or NULL
|
||||
* to get the tag.
|
||||
*
|
||||
*
|
||||
* @param string|null $name The name of an attribute to get the value of,
|
||||
* or NULL to get the tag.
|
||||
*
|
||||
* @return string|resource The value of the specified attribute,
|
||||
* or the tag if NULL is provided.
|
||||
*/
|
||||
@ -82,9 +88,9 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sanitizes a name of an attribute (message or query one).
|
||||
*
|
||||
*
|
||||
* @param mixed $name The name to sanitize.
|
||||
*
|
||||
*
|
||||
* @return string The sanitized name.
|
||||
*/
|
||||
public static function sanitizeAttributeName($name)
|
||||
@ -103,10 +109,10 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sanitizes a value of an attribute (message or query one).
|
||||
*
|
||||
*
|
||||
* @param mixed $value The value to sanitize.
|
||||
*
|
||||
* @return string The sanitized value.
|
||||
*
|
||||
* @return string|resource The sanitized value.
|
||||
*/
|
||||
public static function sanitizeAttributeValue($value)
|
||||
{
|
||||
@ -119,8 +125,9 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Gets the tag that the message is associated with.
|
||||
*
|
||||
*
|
||||
* @return string The current tag or NULL if there isn't a tag.
|
||||
*
|
||||
* @see setTag()
|
||||
*/
|
||||
public function getTag()
|
||||
@ -130,13 +137,14 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Sets the tag to associate the request with.
|
||||
*
|
||||
*
|
||||
* Sets the tag to associate the message with. Setting NULL erases the
|
||||
* currently set tag.
|
||||
*
|
||||
*
|
||||
* @param string $tag The tag to set.
|
||||
*
|
||||
*
|
||||
* @return $this The message object.
|
||||
*
|
||||
* @see getTag()
|
||||
*/
|
||||
protected function setTag($tag)
|
||||
@ -147,11 +155,12 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Gets the value of an attribute.
|
||||
*
|
||||
*
|
||||
* @param string $name The name of the attribute.
|
||||
*
|
||||
*
|
||||
* @return string|resource|null The value of the specified attribute.
|
||||
* Returns NULL if such an attribute is not set.
|
||||
*
|
||||
* @see setAttribute()
|
||||
*/
|
||||
protected function getAttribute($name)
|
||||
@ -165,9 +174,10 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Gets all arguments in an array.
|
||||
*
|
||||
*
|
||||
* @return ArrayObject An ArrayObject with the keys being argument names,
|
||||
* and the array values being argument values.
|
||||
*
|
||||
* @see getArgument()
|
||||
* @see setArgument()
|
||||
*/
|
||||
@ -177,40 +187,30 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of arguments.
|
||||
*
|
||||
* @param int $mode The counter mode.
|
||||
* Either COUNT_NORMAL or COUNT_RECURSIVE.
|
||||
* When in normal mode, counts the number of arguments.
|
||||
* When in recursive mode, counts the number of API words
|
||||
* (including the empty word at the end).
|
||||
*
|
||||
* @return int The number of arguments/words.
|
||||
* Counts the number of attributes.
|
||||
*
|
||||
* @return int The number of attributes.
|
||||
*/
|
||||
public function count($mode = COUNT_NORMAL)
|
||||
public function count()
|
||||
{
|
||||
$result = count($this->attributes);
|
||||
if ($mode !== COUNT_NORMAL) {
|
||||
$result += 2/*first+last word*/
|
||||
+ (int)(null !== $this->getTag());
|
||||
}
|
||||
return $result;
|
||||
return count($this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute for the message.
|
||||
*
|
||||
*
|
||||
* @param string $name Name of the attribute.
|
||||
* @param string|resource|null $value Value of the attribute as a string or
|
||||
* seekable stream.
|
||||
* Setting the value to NULL removes an argument of this name.
|
||||
* If a seekable stream is provided, it is sent from its current
|
||||
* posistion to its end, and the pointer is seeked back to its current
|
||||
* position to its end, and the pointer is seeked back to its current
|
||||
* position after sending.
|
||||
* Non seekable streams, as well as all other types, are casted to a
|
||||
* string.
|
||||
*
|
||||
*
|
||||
* @return $this The message object.
|
||||
*
|
||||
* @see getArgument()
|
||||
*/
|
||||
protected function setAttribute($name, $value = '')
|
||||
@ -226,7 +226,7 @@ abstract class Message implements IteratorAggregate, Countable
|
||||
|
||||
/**
|
||||
* Removes all attributes from the message.
|
||||
*
|
||||
*
|
||||
* @return $this The message object.
|
||||
*/
|
||||
protected function removeAllAttributes()
|
||||
|
Reference in New Issue
Block a user