Issues (3641)

Service/ApiQueryBuilderToUtilEncodingBridge.php (1 issue)

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 Spryker\Zed\ApiQueryBuilder\Dependency\Service;
9
10
/**
11
 * @deprecated Not in use anymore.
12
 */
13
class ApiQueryBuilderToUtilEncodingBridge implements ApiQueryBuilderToUtilEncodingInterface
14
{
15
    /**
16
     * @var \Spryker\Service\UtilEncoding\UtilEncodingServiceInterface
17
     */
18
    protected $utilEncodingService;
19
20
    /**
21
     * @param \Spryker\Service\UtilEncoding\UtilEncodingServiceInterface $utilEncodingService
22
     */
23
    public function __construct($utilEncodingService)
24
    {
25
        $this->utilEncodingService = $utilEncodingService;
26
    }
27
28
    /**
29
     * @param array<mixed> $value
30
     * @param int|null $options
31
     * @param int|null $depth
32
     *
33
     * @return string|null
34
     */
35
    public function encodeJson($value, $options = null, $depth = null): ?string
36
    {
37
        return $this->utilEncodingService->encodeJson($value, $options, $depth);
38
    }
39
40
    /**
41
     * @param string $jsonValue
42
     * @param bool $assoc Deprecated: `false` is deprecated, always use `true` for array return.
43
     * @param int|null $depth
44
     * @param int|null $options
45
     *
46
     * @return array<mixed>|null
47
     */
48
    public function decodeJson($jsonValue, $assoc = false, $depth = null, $options = null): ?array
49
    {
50
        if ($assoc === false) {
51
            trigger_error('Param #2 `$assoc` must be `true` as return of type `object` is not accepted.', E_USER_DEPRECATED);
52
        }
53
54
        /** @phpstan-var array<mixed>|null */
55
        return $this->utilEncodingService->decodeJson($jsonValue, $assoc, $depth, $options);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->utilEncodi...ssoc, $depth, $options) could return the type object which is incompatible with the type-hinted return array|null. Consider adding an additional type-check to rule them out.
Loading history...
56
    }
57
}
58