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

JsonFormatter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 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