| @@ 19-76 (lines=58) @@ | ||
| 16 | * |
|
| 17 | * @author Beñat Espiña <[email protected]> |
|
| 18 | */ |
|
| 19 | class AcceptAnswerCommand |
|
| 20 | { |
|
| 21 | const URL = '/answers/%s/accept'; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * The API URL. |
|
| 25 | * |
|
| 26 | * @var string |
|
| 27 | */ |
|
| 28 | private $url; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Array that contains StackExchange API params. |
|
| 32 | * |
|
| 33 | * @var array |
|
| 34 | */ |
|
| 35 | private $params; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Constructor. |
|
| 39 | * |
|
| 40 | * @param array|string $id The answer id. Also, it can be multiple ids separated by semicolon. |
|
| 41 | * @param array $params Array that contains StackExchange API params |
|
| 42 | */ |
|
| 43 | public function __construct($id, array $params = ['site' => 'stackoverflow']) |
|
| 44 | { |
|
| 45 | if (empty($params)) { |
|
| 46 | $params = [ |
|
| 47 | 'order' => 'desc', |
|
| 48 | 'sort' => 'activity', |
|
| 49 | 'site' => 'stackoverflow', |
|
| 50 | ]; |
|
| 51 | } |
|
| 52 | ||
| 53 | $this->params = $params; |
|
| 54 | $this->url = sprintf(self::URL, $id); |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * The API URL. |
|
| 59 | * |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | public function url() |
|
| 63 | { |
|
| 64 | return $this->url; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Gets the params. |
|
| 69 | * |
|
| 70 | * @return array |
|
| 71 | */ |
|
| 72 | public function params() |
|
| 73 | { |
|
| 74 | return $this->params; |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| @@ 19-75 (lines=57) @@ | ||
| 16 | * |
|
| 17 | * @author Beñat Espiña <[email protected]> |
|
| 18 | */ |
|
| 19 | class AllAnswersCommand |
|
| 20 | { |
|
| 21 | const URL = '/answers'; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * The API URL. |
|
| 25 | * |
|
| 26 | * @var string |
|
| 27 | */ |
|
| 28 | private $url; |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Array that contains StackExchange API params. |
|
| 32 | * |
|
| 33 | * @var array |
|
| 34 | */ |
|
| 35 | private $params; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Constructor. |
|
| 39 | * |
|
| 40 | * @param array $params Array that contains StackExchange API params |
|
| 41 | */ |
|
| 42 | public function __construct(array $params = ['site' => 'stackoverflow']) |
|
| 43 | { |
|
| 44 | if (empty($params)) { |
|
| 45 | $params = [ |
|
| 46 | 'order' => 'desc', |
|
| 47 | 'sort' => 'activity', |
|
| 48 | 'site' => 'stackoverflow', |
|
| 49 | ]; |
|
| 50 | } |
|
| 51 | ||
| 52 | $this->params = $params; |
|
| 53 | $this->url = self::URL; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * The API URL. |
|
| 58 | * |
|
| 59 | * @return string |
|
| 60 | */ |
|
| 61 | public function url() |
|
| 62 | { |
|
| 63 | return $this->url; |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Gets the params. |
|
| 68 | * |
|
| 69 | * @return array |
|
| 70 | */ |
|
| 71 | public function params() |
|
| 72 | { |
|
| 73 | return $this->params; |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||