Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| Format | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Config; |
| 4 | |
| 5 | use CodeIgniter\Config\BaseConfig; |
| 6 | use CodeIgniter\Format\JSONFormatter; |
| 7 | use CodeIgniter\Format\XMLFormatter; |
| 8 | |
| 9 | class Format extends BaseConfig |
| 10 | { |
| 11 | /** |
| 12 | * -------------------------------------------------------------------------- |
| 13 | * Available Response Formats |
| 14 | * -------------------------------------------------------------------------- |
| 15 | * |
| 16 | * When you perform content negotiation with the request, these are the |
| 17 | * available formats that your application supports. This is currently |
| 18 | * only used with the API\ResponseTrait. A valid Formatter must exist |
| 19 | * for the specified format. |
| 20 | * |
| 21 | * These formats are only checked when the data passed to the respond() |
| 22 | * method is an array. |
| 23 | * |
| 24 | * @var list<string> |
| 25 | */ |
| 26 | public array $supportedResponseFormats = [ |
| 27 | 'application/json', |
| 28 | 'application/xml', // machine-readable XML |
| 29 | 'text/xml', // human-readable XML |
| 30 | ]; |
| 31 | |
| 32 | /** |
| 33 | * -------------------------------------------------------------------------- |
| 34 | * Formatters |
| 35 | * -------------------------------------------------------------------------- |
| 36 | * |
| 37 | * Lists the class to use to format responses with of a particular type. |
| 38 | * For each mime type, list the class that should be used. Formatters |
| 39 | * can be retrieved through the getFormatter() method. |
| 40 | * |
| 41 | * @var array<string, string> |
| 42 | */ |
| 43 | public array $formatters = [ |
| 44 | 'application/json' => JSONFormatter::class, |
| 45 | 'application/xml' => XMLFormatter::class, |
| 46 | 'text/xml' => XMLFormatter::class, |
| 47 | ]; |
| 48 | |
| 49 | /** |
| 50 | * -------------------------------------------------------------------------- |
| 51 | * Formatters Options |
| 52 | * -------------------------------------------------------------------------- |
| 53 | * |
| 54 | * Additional Options to adjust default formatters behaviour. |
| 55 | * For each mime type, list the additional options that should be used. |
| 56 | * |
| 57 | * @var array<string, int> |
| 58 | */ |
| 59 | public array $formatterOptions = [ |
| 60 | 'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, |
| 61 | 'application/xml' => 0, |
| 62 | 'text/xml' => 0, |
| 63 | ]; |
| 64 | |
| 65 | /** |
| 66 | * -------------------------------------------------------------------------- |
| 67 | * Maximum depth for JSON encoding. |
| 68 | * -------------------------------------------------------------------------- |
| 69 | * |
| 70 | * This value determines how deep the JSON encoder will traverse nested structures. |
| 71 | */ |
| 72 | public int $jsonEncodeDepth = 512; |
| 73 | } |