AttributeOptionApiAdapter::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
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\Service\AkeneoPim\Dependencies\External\Api\Adapter\Attributes;
9
10
use Akeneo\Pim\ApiClient\AkeneoPimClientInterface;
0 ignored issues
show
Bug introduced by
The type Akeneo\Pim\ApiClient\AkeneoPimClientInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface;
12
use SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface;
13
use SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface;
14
15
class AttributeOptionApiAdapter implements AttributeOptionApiAdapterInterface
16
{
17
    /**
18
     * @var \Akeneo\Pim\ApiClient\AkeneoPimClientInterface
19
     */
20
    protected $akeneoPimClient;
21
22
    /**
23
     * @var \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface
24
     */
25
    private $wrapperFactory;
26
27
    /**
28
     * @param \Akeneo\Pim\ApiClient\AkeneoPimClientInterface $akeneoPimClient
29
     * @param \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface $wrapperFactory
30
     */
31
    public function __construct(AkeneoPimClientInterface $akeneoPimClient, WrapperFactoryInterface $wrapperFactory)
32
    {
33
        $this->akeneoPimClient = $akeneoPimClient;
34
        $this->wrapperFactory = $wrapperFactory;
35
    }
36
37
    /**
38
     * @param string $attributeCode Code of the attribute
39
     * @param string $code Code of the resource
40
     *
41
     * @return array
42
     */
43
    public function get($attributeCode, $code): array
44
    {
45
        return $this->akeneoPimClient
46
            ->getAttributeOptionApi()
47
            ->get($attributeCode, $code);
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     *
53
     * @param string $attributeCode
54
     * @param int $limit
55
     * @param bool $withCount
56
     * @param array $queryParameters
57
     *
58
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface
59
     */
60
    public function listPerPage($attributeCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface
61
    {
62
        $page = $this->akeneoPimClient
63
            ->getAttributeOptionApi()
64
            ->listPerPage($attributeCode, $limit, $withCount, $queryParameters);
65
66
        return $this->wrapperFactory
67
            ->createAkeneoPage($page);
68
    }
69
70
    /**
71
     * {@inheritDoc}
72
     *
73
     * @param string $attributeCode
74
     * @param int $pageSize
75
     * @param array $queryParameters
76
     *
77
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface
78
     */
79
    public function all($attributeCode, $pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface
80
    {
81
        $resourceCursor = $this->akeneoPimClient
82
            ->getAttributeOptionApi()
83
            ->all($attributeCode, $pageSize, $queryParameters);
84
85
        return $this->wrapperFactory
86
            ->createAkeneoResourceCursor($resourceCursor);
87
    }
88
}
89