Response   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A defaultFormatters() 0 19 2
1
<?php
2
3
namespace yrc\web;
4
5
use yii\web\Response as YiiResponse;
6
use Yii;
7
8
class Response extends YiiResponse
9
{
10
    /**
11
     * @const FORMAT_JSON25519
12
     */
13
    const FORMAT_JSON25519 = 'vnd.json+25519';
14
15
    /**
16
     * @const FORMAT_NCRYPTF_JSON
17
     */
18
    const FORMAT_NCRYPTF_JSON = 'vnd.ncryptf+json';
19
20
    /**
21
     * @return array the formatters that are supported by default
22
     */
23
    protected function defaultFormatters()
24
    {
25
        $formatters = parent::defaultFormatters();
26
27
        foreach ([self::FORMAT_JSON25519, self::FORMAT_NCRYPTF_JSON] as $format) {
28
            $formatters[$format] = [
29
                'class'         => \yrc\web\ncryptf\JsonResponseFormatter::class,
30
                'prettyPrint'   => YII_DEBUG,
31
                'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION,
32
            ];
33
        }
34
35
        $formatters[self::FORMAT_JSON] = [
36
            'class'         => \yrc\web\JsonResponseFormatter::class,
37
            'prettyPrint'   => YII_DEBUG,
38
            'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION,
39
        ];
40
        
41
        return $formatters;
42
    }
43
}
44