$message */ private $message = []; /** * constructor * * @param \Federator\Main $main main instance */ public function __construct(\Federator\Main $main) { $this->main = $main; } /** * run given url path * * @param array $paths path array split by / * @return bool true on success */ public function exec($paths) : bool { $method = $_SERVER["REQUEST_METHOD"]; switch ($method) { case 'GET': switch (sizeof($paths)) { case 3: if ($paths[2] === 'moo') { return $this->getDummy(); } } break; case 'POST': switch (sizeof($paths)) { case 3: if ($paths[2] === 'moo') { return $this->postDummy(); } break; } } $this->main->setResponseCode(404); return false; } /** * get function for "/v1/dummy/moo" * * @return bool */ public function getDummy() { $this->message = [ 'r1' => ' (__) ', 'r2' => ' `------(oo) ', 'r3' => ' || __ (__) ', 'r4' => ' ||w || ', 'r5' => ' ' ]; return true; } /** * post function for /v1/dummy/moo" * * @return bool */ public function postDummy() { return $this->getDummy(); } /** * get internal represenation as json string * * @return string json string */ public function toJson() { return json_encode($this->message, JSON_PRETTY_PRINT) . "\n"; } }