SuperAttributeAkeneoApiReadStream   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 17
c 3
b 0
f 0
dl 0
loc 53
rs 10
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A open() 0 6 1
A eof() 0 10 3
A get() 0 12 4
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\AkeneoPimMiddlewareConnector\Business\Stream\Akeneo;
9
10
class SuperAttributeAkeneoApiReadStream extends AbstractAkeneoApiReadStream
11
{
12
    /**
13
     * @var \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursor
0 ignored issues
show
Bug introduced by
The type SprykerEco\Service\Akene...er\AkeneoResourceCursor 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...
14
     */
15
    protected $cursorVariants;
16
17
    /**
18
     * @var string
19
     */
20
    protected const KEY_CODE = 'code';
21
22
    /**
23
     * @return bool
24
     */
25
    public function open(): bool
26
    {
27
        $this->cursor = $this->akeneoPimService
28
            ->getAllFamilies();
29
30
        return true;
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function get(): array
37
    {
38
        if (($this->cursorVariants !== null) && $this->cursorVariants->valid()) {
39
            return $this->cursorVariants->current();
40
        }
41
42
        $family = $this->cursor->current();
43
        $this->cursor->next();
44
45
        $this->cursorVariants = $this->akeneoPimService->getFamilyVariants($family[static::KEY_CODE]);
46
47
        return $this->cursorVariants->valid() ? $this->cursorVariants->current() : [];
48
    }
49
50
    /**
51
     * @return bool
52
     */
53
    public function eof(): bool
54
    {
55
        $isValidCursorVariants = false;
56
57
        if ($this->cursorVariants !== null) {
58
            $this->cursorVariants->next();
59
            $isValidCursorVariants = $this->cursorVariants->valid();
60
        }
61
62
        return parent::eof() && !$isValidCursorVariants;
63
    }
64
}
65