ZipArchiveAdapter::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace diecoding\flysystem\adapter;
6
7
use diecoding\flysystem\traits\ChecksumAdapterTrait;
8
use diecoding\flysystem\traits\UrlGeneratorAdapterTrait;
9
use League\Flysystem\ChecksumProvider;
10
use League\Flysystem\Config;
11
use League\Flysystem\FileAttributes;
12
use League\Flysystem\FilesystemAdapter;
13
use League\Flysystem\UnixVisibility\VisibilityConverter;
14
use League\Flysystem\UrlGeneration\PublicUrlGenerator;
15
use League\Flysystem\UrlGeneration\TemporaryUrlGenerator;
16
use League\Flysystem\ZipArchive\ZipArchiveAdapter as LeagueZipArchiveAdapter;
17
use League\Flysystem\ZipArchive\ZipArchiveProvider;
18
use League\MimeTypeDetection\MimeTypeDetector;
19
20
/**
21
 * This properties for fixed issue https://scrutinizer-ci.com/g/sugeng-sulistiyawan/yii2-flysystem/inspections/22f77797-37d0-419a-9447-ab6111572e99/issues/?status=all
22
 * @property string $action
23
 * @property string $prefix
24
 */
25
final class ZipArchiveAdapter implements FilesystemAdapter, ChecksumProvider, PublicUrlGenerator, TemporaryUrlGenerator
26
{
27
    use UrlGeneratorAdapterTrait, ChecksumAdapterTrait;
28
29
    /**
30
     * @var bool
31
     */
32
    public $skipPrefixer = true;
33
34
    /**
35
     * @var LeagueZipArchiveAdapter
36
     */
37
    private $_adapter;
38
39
    public function __construct(
40
        private ZipArchiveProvider $zipArchiveProvider,
41
        string $root = '',
42
        ?MimeTypeDetector $mimeTypeDetector = null,
43
        ?VisibilityConverter $visibility = null,
44
        private bool $detectMimeTypeUsingPath = false,
45
    ) {
46
        $this->setAdapter(new LeagueZipArchiveAdapter($zipArchiveProvider, $root, $mimeTypeDetector, $visibility, $detectMimeTypeUsingPath));
47
    }
48
49
    /**
50
     * @return LeagueZipArchiveAdapter
51
     */
52
    public function getAdapter()
53
    {
54
        return $this->_adapter;
55
    }
56
57
    /**
58
     * @param LeagueZipArchiveAdapter $value
59
     * @return void
60
     */
61
    public function setAdapter(LeagueZipArchiveAdapter $value)
62
    {
63
        $this->_adapter = $value;
64
    }
65
66
    public function fileExists(string $path): bool
67
    {
68
        return $this->getAdapter()->fileExists($path);
69
    }
70
71
    public function write(string $path, string $contents, Config $config): void
72
    {
73
        $this->getAdapter()->write($path, $contents, $config);
74
    }
75
76
    public function writeStream(string $path, $contents, Config $config): void
77
    {
78
        $this->getAdapter()->writeStream($path, $contents, $config);
79
    }
80
81
    public function read(string $path): string
82
    {
83
        return $this->getAdapter()->read($path);
84
    }
85
86
    public function readStream(string $path)
87
    {
88
        return $this->getAdapter()->readStream($path);
89
    }
90
91
    public function delete(string $path): void
92
    {
93
        $this->getAdapter()->delete($path);
94
    }
95
96
    public function deleteDirectory(string $path): void
97
    {
98
        $this->getAdapter()->deleteDirectory($path);
99
    }
100
101
    public function createDirectory(string $path, Config $config): void
102
    {
103
        $this->getAdapter()->createDirectory($path, $config);
104
    }
105
106
    public function directoryExists(string $path): bool
107
    {
108
        return $this->getAdapter()->directoryExists($path);
109
    }
110
111
    public function setVisibility(string $path, string $visibility): void
112
    {
113
        $this->getAdapter()->setVisibility($path, $visibility);
114
    }
115
116
    public function visibility(string $path): FileAttributes
117
    {
118
        return $this->getAdapter()->visibility($path);
119
    }
120
121
    public function mimeType(string $path): FileAttributes
122
    {
123
        return $this->getAdapter()->mimeType($path);
124
    }
125
126
    public function lastModified(string $path): FileAttributes
127
    {
128
        return $this->getAdapter()->lastModified($path);
129
    }
130
131
    public function fileSize(string $path): FileAttributes
132
    {
133
        return $this->getAdapter()->fileSize($path);
134
    }
135
136
    public function listContents(string $path, bool $deep): iterable
137
    {
138
        return $this->getAdapter()->listContents($path, $deep);
139
    }
140
141
    public function move(string $source, string $destination, Config $config): void
142
    {
143
        $this->getAdapter()->move($source, $destination, $config);
144
    }
145
146
    public function copy(string $source, string $destination, Config $config): void
147
    {
148
        $this->getAdapter()->copy($source, $destination, $config);
149
    }
150
}
151