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\Json; |
9
|
|
|
|
10
|
|
|
use SprykerMiddleware\Shared\Process\Stream\WriteStreamInterface; |
|
|
|
|
11
|
|
|
use SprykerMiddleware\Zed\Process\Business\Exception\MethodNotSupportedException; |
|
|
|
|
12
|
|
|
|
13
|
|
|
class JsonSuperAttributeWriteStream implements WriteStreamInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var resource |
17
|
|
|
*/ |
18
|
|
|
protected $handle; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $path; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
protected $data = []; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param string $path |
32
|
|
|
*/ |
33
|
|
|
public function __construct(string $path) |
34
|
|
|
{ |
35
|
|
|
$this->path = $path; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return bool |
40
|
|
|
*/ |
41
|
|
|
public function open(): bool |
42
|
|
|
{ |
43
|
|
|
$this->handle = fopen($this->path, 'w'); |
44
|
|
|
|
45
|
|
|
if ($this->handle === false) { |
46
|
|
|
return false; |
47
|
|
|
} |
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
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
|
|
public function close(): bool |
69
|
|
|
{ |
70
|
|
|
if ($this->handle) { |
71
|
|
|
return fclose($this->handle); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return false; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @throws \SprykerMiddleware\Zed\Process\Business\Exception\MethodNotSupportedException |
79
|
|
|
* |
80
|
|
|
* @return bool |
81
|
|
|
*/ |
82
|
|
|
public function eof(): bool |
83
|
|
|
{ |
84
|
|
|
throw new MethodNotSupportedException(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param array $data |
89
|
|
|
* |
90
|
|
|
* @return int |
91
|
|
|
*/ |
92
|
|
|
public function write(array $data): int |
93
|
|
|
{ |
94
|
|
|
if (array_key_exists('variant_attribute_sets', $data)) { |
95
|
|
|
foreach ($data['variant_attribute_sets'] as $axes) { |
96
|
|
|
foreach ($axes['axes'] as $axe) { |
97
|
|
|
!in_array($axe, $this->data) ? $this->data[] = $axe : null; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return 1; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
public function flush(): bool |
109
|
|
|
{ |
110
|
|
|
fwrite($this->handle, json_encode($this->data)); |
111
|
|
|
|
112
|
|
|
return fflush($this->handle); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths