AttributeApiAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 74
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A listPerPage() 0 8 1
A get() 0 5 1
A __construct() 0 4 1
A all() 0 8 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\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\Adapter\ApiAdapterInterface;
12
use SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface;
13
use SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface;
14
use SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface;
15
16
class AttributeApiAdapter implements ApiAdapterInterface
17
{
18
    /**
19
     * @var \Akeneo\Pim\ApiClient\AkeneoPimClientInterface
20
     */
21
    protected $akeneoPimClient;
22
23
    /**
24
     * @var \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface
25
     */
26
    private $wrapperFactory;
27
28
    /**
29
     * @param \Akeneo\Pim\ApiClient\AkeneoPimClientInterface $akeneoPimClient
30
     * @param \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface $wrapperFactory
31
     */
32
    public function __construct(AkeneoPimClientInterface $akeneoPimClient, WrapperFactoryInterface $wrapperFactory)
33
    {
34
        $this->akeneoPimClient = $akeneoPimClient;
35
        $this->wrapperFactory = $wrapperFactory;
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     *
41
     * @param string $code Code of the resource
42
     *
43
     * @return array
44
     */
45
    public function get($code): array
46
    {
47
        return $this->akeneoPimClient
48
            ->getAttributeApi()
49
            ->get($code);
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     *
55
     * @param int $limit The maximum number of resources to return.
56
     *                               Do note that the server has a maximum limit allowed.
57
     * @param bool $withCount Set to true to return the total count of resources.
58
     *                               This parameter could decrease drastically the performance when set to true.
59
     * @param array $queryParameters Additional query parameters to pass in the request.
60
     *
61
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface
62
     */
63
    public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface
64
    {
65
        $page = $this->akeneoPimClient
66
            ->getAttributeApi()
67
            ->listPerPage($limit, $withCount, $queryParameters);
68
69
        return $this->wrapperFactory
70
            ->createAkeneoPage($page);
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     *
76
     * @param int $pageSize The size of the page returned by the server.
77
     *                               Do note that the server has a maximum limit allowed.
78
     * @param array $queryParameters Additional query parameters to pass in the request
79
     *
80
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface
81
     */
82
    public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface
83
    {
84
        $resourceCursor = $this->akeneoPimClient
85
            ->getAttributeApi()
86
            ->all($pageSize, $queryParameters);
87
88
        return $this->wrapperFactory
89
            ->createAkeneoResourceCursor($resourceCursor);
90
    }
91
}
92