Passed
Push — master ( f03a56...8d49be )
by Dominik
02:42
created

JsonTransformer::__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
c 0
b 0
f 0
dl 0
loc 5
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\Deserialization\Transformer;
6
7
final class JsonTransformer implements TransformerInterface
8
{
9
    /**
10
     * @var int
11
     */
12
    private $level;
13
14
    /**
15
     * @var int
16
     */
17
    private $options;
18
19
    /**
20
     * JsonTransformer constructor.
21
     *
22
     * @param int $options
23
     * @param int $level
24
     */
25 1
    public function __construct(int $level = 512, int $options = 0)
26
    {
27 1
        $this->options = $options;
28 1
        $this->level = $level;
29 1
    }
30
31
    /**
32
     * @param string $string
33
     *
34
     * @return array
35
     */
36 1
    public function transform(string $string): array
37
    {
38 1
        return json_decode($string, true, $this->level, $this->options);
39
    }
40
}
41