Passed
Pull Request — master (#88)
by Olha
14:57
created

PayoneToUtilEncodingServiceBridge::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Dependency\Service;
9
10
use Spryker\Service\UtilEncoding\UtilEncodingServiceInterface;
11
12
class PayoneToUtilEncodingServiceBridge implements PayoneToUtilEncodingServiceInterface
13
{
14
    /**
15
     * @var \Spryker\Service\UtilEncoding\UtilEncodingServiceInterface
16
     */
17
    protected UtilEncodingServiceInterface $utilEncodingService;
18
19
    /**
20
     * @param \Spryker\Service\UtilEncoding\UtilEncodingServiceInterface $utilEncodingService
21
     */
22
    public function __construct($utilEncodingService)
23
    {
24
        $this->utilEncodingService = $utilEncodingService;
25
    }
26
27
    /**
28
     * @param string $jsonValue
29
     * @param bool $assoc Deprecated: `false` is deprecated, always use `true` for array return.
30
     * @param int|null $depth
31
     * @param int|null $options
32
     *
33
     * @return object|array<mixed>|null
34
     */
35
    public function decodeJson(string $jsonValue, bool $assoc = false, ?int $depth = null, ?int $options = null)
36
    {
37
        if ($assoc === false) {
38
            trigger_error('Param #2 `$assoc` must be `true` as return of type `object` is not accepted.', E_USER_DEPRECATED);
39
        }
40
41
        /** @phpstan-var array<mixed>|null */
42
        return $this->utilEncodingService->decodeJson($jsonValue, $assoc, $depth, $options);
43
    }
44
}
45