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