Passed
Pull Request — master (#88)
by Olha
05:01
created

PayoneToUtilEncodingServiceBridge   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A decodeJson() 0 8 2
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