query = Controller\Controller::createQuery( explode('/', trim($_SERVER['PATH_INFO'] ?? '/api', '/')), $_SERVER['REQUEST_METHOD'], $this->generateContent($_SERVER['REQUEST_METHOD']) ); return $this; } /** * Generates the content of the query based on the request type. * * @param string $request The request method on which to base the content. * * @return array */ public function generateContent (string $request): array { $content; switch ($request) { case "GET": // GET should always be empty case "POST": // POST contains moves, account info, etc. default: $content = $_REQUEST; } return $content; } /** * Communicates with the controller to generate the JSON result. * * @return string */ public function generateResult (): string { $this->result = Controller\Controller::createResult( "", array() ); // generate result return json_encode(array( "Result-Type" => $this->result->getResultType(), "Content" => $this->result->getResult() )); } }