DataImportWriteStream::flush()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
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\DataImport;
9
10
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Plugin\DataImporterPluginInterface;
11
use SprykerMiddleware\Shared\Process\Stream\WriteStreamInterface;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Shared...am\WriteStreamInterface 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\Zed\Process\Business\Exception\MethodNotSupportedException;
0 ignored issues
show
Bug introduced by
The type SprykerMiddleware\Zed\Pr...odNotSupportedException 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 DataImportWriteStream implements WriteStreamInterface
15
{
16
    /**
17
     * @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Plugin\DataImporterPluginInterface
18
     */
19
    protected $dataImporterPlugin;
20
21
    /**
22
     * @var array
23
     */
24
    protected $data = [];
25
26
    /**
27
     * @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Plugin\DataImporterPluginInterface $dataImporterPlugin
28
     */
29
    public function __construct(DataImporterPluginInterface $dataImporterPlugin)
30
    {
31
        $this->dataImporterPlugin = $dataImporterPlugin;
32
    }
33
34
    /**
35
     * @return bool
36
     */
37
    public function open(): bool
38
    {
39
        $this->data = [];
40
41
        return true;
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function close(): bool
48
    {
49
        return true;
50
    }
51
52
    /**
53
     * @param int $offset
54
     * @param int $whence
55
     *
56
     * @throws \SprykerMiddleware\Zed\Process\Business\Exception\MethodNotSupportedException
57
     *
58
     * @return int
59
     */
60
    public function seek(int $offset, int $whence): int
61
    {
62
        throw new MethodNotSupportedException();
63
    }
64
65
    /**
66
     * @throws \SprykerMiddleware\Zed\Process\Business\Exception\MethodNotSupportedException
67
     *
68
     * @return bool
69
     */
70
    public function eof(): bool
71
    {
72
        throw new MethodNotSupportedException();
73
    }
74
75
    /**
76
     * @param array $data
77
     *
78
     * @return int
79
     */
80
    public function write(array $data): int
81
    {
82
        $this->data[] = $data;
83
84
        return 1;
85
    }
86
87
    /**
88
     * @return bool
89
     */
90
    public function flush(): bool
91
    {
92
        $this->dataImporterPlugin->import($this->data);
93
94
        return true;
95
    }
96
}
97