Passed
Pull Request — master (#75)
by
unknown
14:51
created

JSONConverter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 10
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convert() 0 4 1
A getFormat() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Stream\Data;
6
7
final class JSONConverter implements Converter
8
{
9
    public static function getFormat(): string
10
    {
11
        return 'application/json';
12
    }
13
    public function convert($data, array $params = []): string
14
    {
15
        // of course you can use JsonSerializer
16
        return json_encode($data, JSON_PRETTY_PRINT|JSON_INVALID_UTF8_IGNORE|JSON_UNESCAPED_UNICODE);
17
    }
18
}
19