Passed
Push — master ( 0e7d9c...4d448d )
by Dominik
02:31
created

JsonFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A format() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Formatter;
6
7
final class JsonFormatter implements FormatterInterface
8
{
9
    /**
10
     * @var int
11
     */
12
    private $options;
13
14
    /**
15
     * @var int
16
     */
17
    private $level;
18
19
    /**
20
     * JsonFormatter constructor.
21
     *
22
     * @param int $options
23
     * @param int $level
24
     */
25 1
    public function __construct(int $options = 0, int $level = 512)
26
    {
27 1
        $this->options = $options;
28 1
        $this->level = $level;
29 1
    }
30
31
    /**
32
     * @param array $data
33
     *
34
     * @return string
35
     */
36 1
    public function format(array $data): string
37
    {
38 1
        return json_encode($data, $this->options, $this->level);
39
    }
40
}
41