-
Notifications
You must be signed in to change notification settings - Fork 18
/
StubZipArchive.php
112 lines (88 loc) · 2.43 KB
/
StubZipArchive.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
declare(strict_types=1);
namespace League\Flysystem\ZipArchive;
use ZipArchive;
class StubZipArchive extends ZipArchive
{
private bool $failNextDirectoryCreation = false;
private bool $failNextWrite = false;
private bool $failNextDeleteName = false;
private bool $failWhenSettingVisibility = false;
private bool $failWhenDeletingAnIndex = false;
public function failNextDirectoryCreation(): void
{
$this->failNextDirectoryCreation = true;
}
/**
* @param string $dirname
* @param int $flags
*
* @return bool
*/
public function addEmptyDir($dirname, $flags = 0): bool
{
if ($this->failNextDirectoryCreation) {
$this->failNextDirectoryCreation = false;
return false;
}
return parent::addEmptyDir($dirname);
}
public function failNextWrite(): void
{
$this->failNextWrite = true;
}
/**
* @param string $localname
* @param string $contents
* @param int $flags
*
* @return bool
*/
public function addFromString($localname, $contents, $flags = 0): bool
{
if ($this->failNextWrite) {
$this->failNextWrite = false;
return false;
}
return parent::addFromString($localname, $contents);
}
public function failNextDeleteName(): void
{
$this->failNextDeleteName = true;
}
/**
* @return bool
*/
public function deleteName($name): bool
{
if ($this->failNextDeleteName) {
$this->failNextDeleteName = false;
return false;
}
return parent::deleteName($name);
}
public function failWhenSettingVisibility(): void
{
$this->failWhenSettingVisibility = true;
}
public function setExternalAttributesName($name, $opsys, $attr, $flags = null): bool
{
if ($this->failWhenSettingVisibility) {
$this->failWhenSettingVisibility = false;
return false;
}
return parent::setExternalAttributesName($name, $opsys, $attr);
}
public function failWhenDeletingAnIndex(): void
{
$this->failWhenDeletingAnIndex = true;
}
public function deleteIndex($index): bool
{
if ($this->failWhenDeletingAnIndex) {
$this->failWhenDeletingAnIndex = false;
return false;
}
return parent::deleteIndex($index);
}
}