PropelCriteriaReadStream::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 7
rs 10
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\Db;
9
10
use Propel\Runtime\ActiveQuery\ModelCriteria;
0 ignored issues
show
Bug introduced by
The type Propel\Runtime\ActiveQuery\ModelCriteria 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 SprykerMiddleware\Shared\Process\Stream\ReadStreamInterface;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Shared...eam\ReadStreamInterface 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...
12
use SprykerMiddleware\Shared\Process\Stream\StreamInterface;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Shared...\Stream\StreamInterface 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...
13
14
class PropelCriteriaReadStream implements StreamInterface, ReadStreamInterface
15
{
16
    /**
17
     * @var \Propel\Runtime\ActiveQuery\ModelCriteria
18
     */
19
    protected $modelCriteria;
20
21
    /**
22
     * @var \Propel\Runtime\Collection\CollectionIterator
0 ignored issues
show
Bug introduced by
The type Propel\Runtime\Collection\CollectionIterator 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...
23
     */
24
    protected $iterator;
25
26
    /**
27
     * @param \Propel\Runtime\ActiveQuery\ModelCriteria $modelCriteria
28
     */
29
    public function __construct(ModelCriteria $modelCriteria)
30
    {
31
        $this->modelCriteria = $modelCriteria;
32
    }
33
34
    /**
35
     * @return mixed
36
     */
37
    public function read()
38
    {
39
        return $this->get();
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45
    public function get()
46
    {
47
        $item = $this->iterator
48
            ->current();
49
        $this->iterator->next();
50
51
        return $item;
52
    }
53
54
    /**
55
     * @return bool
56
     */
57
    public function open(): bool
58
    {
59
        $this->iterator = $this->modelCriteria
60
            ->find()
61
            ->getIterator();
62
63
        return true;
64
    }
65
66
    /**
67
     * @return bool
68
     */
69
    public function close(): bool
70
    {
71
        unset($this->iterator);
72
73
        return true;
74
    }
75
76
    /**
77
     * @param int $offset
78
     * @param int $whence
79
     *
80
     * @return int
81
     */
82
    public function seek(int $offset, int $whence): int
83
    {
84
        if ($whence === SEEK_SET) {
85
            $this->iterator->seek($offset);
86
87
            return 0;
88
        }
89
90
        return -1;
91
    }
92
93
    /**
94
     * @return bool
95
     */
96
    public function eof(): bool
97
    {
98
        return !$this->iterator->valid();
99
    }
100
}
101