/** * GETs a single Emoji. * * @param ServerRequestInterface ServerRequestInterface $request PSR-7 standard for receiving client request * @param ResponseInterface ResponseInterface $response PSR-& standard for sending server response * * @return ResponseInterface HTTP response of client request */ public function show(ServerRequestInterface $request, ResponseInterface $response, $argc) { //Get the single Emoji with the id from route $emoji = Emoji::find($argc['id']); //Check if the Emoji with the id exist if ($emoji != null) { //Build Emoji data to return $result = $this->buildEmojiData($emoji); } else { //Repond with 404 if Emoji not found $response = $response->withStatus(404); $result = ['message' => 'Emoji not found']; } //Write message to response interface $response->getBody()->write(json_encode($result)); //Return response return $response; }