FamilyVariantApiAdapter   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 __construct() 0 4 1
A get() 0 5 1
A all() 0 8 1
A listPerPage() 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\Family;
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 FamilyVariantApiAdapter implements FamilyVariantApiAdapterInterface
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
     * {@inheritDoc}
39
     *
40
     * @param string $familyCode Code of the parent family
41
     * @param string $familyVariantCode Code of the family variant
42
     *
43
     * @return array
44
     */
45
    public function get($familyCode, $familyVariantCode): array
46
    {
47
        return $this->akeneoPimClient
48
            ->getFamilyVariantApi()
49
            ->get($familyCode, $familyVariantCode);
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     *
55
     * @param string $familyCode
56
     * @param int $limit
57
     * @param bool $withCount
58
     * @param array $queryParameters
59
     *
60
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface
61
     */
62
    public function listPerPage($familyCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface
63
    {
64
        $page = $this->akeneoPimClient
65
            ->getFamilyVariantApi()
66
            ->listPerPage($familyCode, $limit, $withCount, $queryParameters);
67
68
        return $this->wrapperFactory
69
            ->createAkeneoPage($page);
70
    }
71
72
    /**
73
     * {@inheritDoc}
74
     *
75
     * @param string $familyCode
76
     * @param int $pageSize
77
     * @param array $queryParameters
78
     *
79
     * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface
80
     */
81
    public function all($familyCode, $pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface
82
    {
83
        $resourceCursor = $this->akeneoPimClient
84
            ->getFamilyVariantApi()
85
            ->all($familyCode, $pageSize, $queryParameters);
86
87
        return $this->wrapperFactory
88
            ->createAkeneoResourceCursor($resourceCursor);
89
    }
90
}
91