Browse Source

added interface for query, comments in code updated

tags/0.2
Paul Rock 7 years ago
parent
commit
6220b421d7
  1. 40
      src/Interfaces/QueryInterface.php
  2. 22
      src/Query.php

40
src/Interfaces/QueryInterface.php

@ -0,0 +1,40 @@
<?php
namespace RouterOS\Interfaces;
/**
* Interface QueryInterface
* @package RouterOS\Interfaces
* @since 0.2
*/
interface QueryInterface
{
/**
* Append to array yet another attribute of query
*
* @param string $word
* @return $this
*/
public function add(string $word): self;
/**
* Get attributes array of current query
*
* @return array
*/
public function getAttributes(): array;
/**
* Get endpoint of current query
*
* @return string
*/
public function getEndpoint(): string;
/**
* Build body of query
*
* @return array
*/
public function getQuery(): array;
}

22
src/Query.php

@ -2,9 +2,15 @@
namespace RouterOS; namespace RouterOS;
class Query
{
use RouterOS\Interfaces\QueryInterface;
/**
* Class Query
* @package RouterOS
* @since 0.1
*/
class Query implements QueryInterface
{
/** /**
* Array of query attributes * Array of query attributes
* @var array * @var array
@ -31,16 +37,18 @@ class Query
* Append to array yet another attribute of query * Append to array yet another attribute of query
* *
* @param string $word * @param string $word
* @return $this
* @return QueryInterface
*/ */
public function add(string $word): self
public function add(string $word): QueryInterface
{ {
$this->_attributes[] = $word; $this->_attributes[] = $word;
return $this; return $this;
} }
/** /**
* @return array
* Get attributes array of current query
*
* @return array
*/ */
public function getAttributes(): array public function getAttributes(): array
{ {
@ -48,7 +56,9 @@ class Query
} }
/** /**
* @return string
* Get endpoint of current query
*
* @return string
*/ */
public function getEndpoint(): string public function getEndpoint(): string
{ {

Loading…
Cancel
Save