Overview

Namespaces

  • Racoon
    • Api
      • Auth
      • Exception
      • Response
        • Format
        • Generate
      • Schema

Classes

  • Racoon\Api\App
  • Racoon\Api\Auth\ApiKeyAuthenticator
  • Racoon\Api\Auth\NoAuthenticator
  • Racoon\Api\Controller
  • Racoon\Api\Request
  • Racoon\Api\Response\Format\JsonFormatter
  • Racoon\Api\Response\Generate\DetailedResponse
  • Racoon\Api\Schema\Item
  • Racoon\Api\Schema\Schema
  • Racoon\Api\Schema\Translator

Interfaces

  • Racoon\Api\Auth\AuthInterface
  • Racoon\Api\Response\Format\FormatterInterface
  • Racoon\Api\Response\Generate\GeneratorInterface

Exceptions

  • Racoon\Api\Exception\AuthenticationException
  • Racoon\Api\Exception\Exception
  • Racoon\Api\Exception\InvalidArgumentException
  • Racoon\Api\Exception\InvalidJsonException
  • Racoon\Api\Exception\InvalidRouteException
  • Racoon\Api\Exception\NotFoundException
  • Racoon\Api\Exception\ResponseFormattingException
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Racoon\Api\Response\Format;
 4: 
 5: 
 6: use Racoon\Api\Exception\ResponseFormattingException;
 7: 
 8: class JsonFormatter implements FormatterInterface
 9: {
10: 
11:     /**
12:      * @param $response
13:      * @return string
14:      * @throws ResponseFormattingException
15:      */
16:     public function format($response)
17:     {
18:         $formattedResponse = json_encode($response);
19: 
20:         if ($formattedResponse === false) {
21:             throw new ResponseFormattingException(null, 'Could not JSON encode the response.');
22:         }
23: 
24:         return $formattedResponse;
25:     }
26: 
27: 
28:     /**
29:      * @return null|string
30:      */
31:     public function getContentType()
32:     {
33:         return 'application/json';
34:     }
35: }
API documentation generated by ApiGen