Skip to content

Commit 19f9bd8

Browse files
committed
Init league/flysystem-v3
1 parent 9650ef3 commit 19f9bd8

File tree

6 files changed

+37
-63
lines changed

6 files changed

+37
-63
lines changed

src/AdapterCollection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use ArrayIterator;
1717
use Iterator;
18-
use League\Flysystem\AdapterInterface;
18+
use League\Flysystem\FilesystemAdapter;
1919
use RuntimeException;
2020

2121
/**
@@ -38,13 +38,13 @@ public function __construct()
3838

3939
/**
4040
* @param string $name Name
41-
* @param \League\Flysystem\AdapterInterface $adapter Adapter
41+
* @param \League\Flysystem\FilesystemAdapter $adapter Adapter
4242
*
4343
* @throws \RuntimeException
4444
*
4545
* @return void
4646
*/
47-
public function add($name, AdapterInterface $adapter)
47+
public function add($name, FilesystemAdapter $adapter)
4848
{
4949
if ($this->has($name)) {
5050
throw new RuntimeException(sprintf(
@@ -81,9 +81,9 @@ public function has(string $name): bool
8181
*
8282
* @throws \RuntimeException
8383
*
84-
* @return \League\Flysystem\AdapterInterface
84+
* @return \League\Flysystem\FilesystemAdapter
8585
*/
86-
public function get(string $name): AdapterInterface
86+
public function get(string $name): FilesystemAdapter
8787
{
8888
if (!$this->has($name)) {
8989
throw new RuntimeException(sprintf(

src/AdapterCollectionInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace PhpCollective\Infrastructure\Storage;
1515

1616
use IteratorAggregate;
17-
use League\Flysystem\AdapterInterface;
17+
use League\Flysystem\FilesystemAdapter;
1818

1919
/**
2020
* Factory Collection Interface
@@ -23,11 +23,11 @@ interface AdapterCollectionInterface extends IteratorAggregate
2323
{
2424
/**
2525
* @param string $name Name
26-
* @param \League\Flysystem\AdapterInterface $adapter Adapter
26+
* @param \League\Flysystem\FilesystemAdapter $adapter Adapter
2727
*
2828
* @return void
2929
*/
30-
public function add($name, AdapterInterface $adapter);
30+
public function add($name, FilesystemAdapter $adapter);
3131

3232
/**
3333
* @param string $name Name
@@ -46,9 +46,9 @@ public function has(string $name): bool;
4646
/**
4747
* @param string $name
4848
*
49-
* @return \League\Flysystem\AdapterInterface
49+
* @return \League\Flysystem\FilesystemAdapter
5050
*/
51-
public function get(string $name): AdapterInterface;
51+
public function get(string $name): FilesystemAdapter;
5252

5353
/**
5454
* Empties the collection

src/FileStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
namespace PhpCollective\Infrastructure\Storage;
1616

1717
use InvalidArgumentException;
18-
use League\Flysystem\AdapterInterface;
1918
use League\Flysystem\Config;
19+
use League\Flysystem\FilesystemAdapter;
2020
use PhpCollective\Infrastructure\Storage\PathBuilder\PathBuilderInterface;
2121
use PhpCollective\Infrastructure\Storage\Processor\Exception\VariantDoesNotExistException;
2222
use PhpCollective\Infrastructure\Storage\Processor\Exception\VariantException;
@@ -203,9 +203,9 @@ public function removeVariant(FileInterface $file, string $name): FileInterface
203203
*
204204
* @param string $storage Storage name to use
205205
*
206-
* @return \League\Flysystem\AdapterInterface
206+
* @return \League\Flysystem\FilesystemAdapter
207207
*/
208-
public function getStorage(string $storage): AdapterInterface
208+
public function getStorage(string $storage): FilesystemAdapter
209209
{
210210
return $this->storageService->adapter($storage);
211211
}

src/FileStorageInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
namespace PhpCollective\Infrastructure\Storage;
1616

17-
use League\Flysystem\AdapterInterface;
1817
use League\Flysystem\Config;
18+
use League\Flysystem\FilesystemAdapter;
1919

2020
/**
2121
* FileStorageInterface
@@ -55,7 +55,7 @@ public function removeVariant(FileInterface $file, string $name): FileInterface;
5555
*
5656
* @param string $storage Storage name to use
5757
*
58-
* @return \League\Flysystem\AdapterInterface
58+
* @return \League\Flysystem\FilesystemAdapter
5959
*/
60-
public function getStorage(string $storage): AdapterInterface;
60+
public function getStorage(string $storage): FilesystemAdapter;
6161
}

src/StorageService.php

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
namespace PhpCollective\Infrastructure\Storage;
1616

17-
use League\Flysystem\AdapterInterface;
1817
use League\Flysystem\Config;
19-
use PhpCollective\Infrastructure\Storage\Exception\StorageException;
18+
use League\Flysystem\FilesystemAdapter;
2019
use PhpCollective\Infrastructure\Storage\Factories\Exception\FactoryNotFoundException;
2120
use RuntimeException;
2221

@@ -81,7 +80,7 @@ public function adapters(): AdapterCollectionInterface
8180
*
8281
* @throws \PhpCollective\Infrastructure\Storage\Factories\Exception\FactoryNotFoundException
8382
*/
84-
public function adapter(string $name): AdapterInterface
83+
public function adapter(string $name): FilesystemAdapter
8584
{
8685
if ($this->adapterCollection->has($name)) {
8786
return $this->adapterCollection->get($name);
@@ -103,9 +102,9 @@ public function adapter(string $name): AdapterInterface
103102
* @param string $adapter Adapter
104103
* @param array $options
105104
*
106-
* @return \League\Flysystem\AdapterInterface
105+
* @return \League\Flysystem\FilesystemAdapter
107106
*/
108-
public function loadAdapter(string $name, string $adapter, array $options): AdapterInterface
107+
public function loadAdapter(string $name, string $adapter, array $options): FilesystemAdapter
109108
{
110109
$adapter = $this->adapterFactory->buildStorageAdapter(
111110
$adapter,
@@ -174,45 +173,20 @@ protected function makeConfigIfNeeded(?Config $config)
174173

175174
/**
176175
* @inheritDoc
177-
*
178-
* @throws \PhpCollective\Infrastructure\Storage\Exception\StorageException
179176
*/
180-
public function storeResource(string $adapter, string $path, $resource, ?Config $config = null): array
177+
public function storeResource(string $adapter, string $path, $resource, ?Config $config = null): void
181178
{
182179
$config = $this->makeConfigIfNeeded($config);
183-
$result = $this->adapter($adapter)->writeStream($path, $resource, $config);
184-
185-
if ($result === false) {
186-
throw new StorageException(sprintf(
187-
'Failed to store resource stream to in `%s` with path `%s`',
188-
$adapter,
189-
$path,
190-
));
191-
}
192-
193-
return $result;
180+
$this->adapter($adapter)->writeStream($path, $resource, $config);
194181
}
195182

196183
/**
197184
* @inheritDoc
198-
*
199-
* @throws \PhpCollective\Infrastructure\Storage\Exception\StorageException
200185
*/
201-
public function storeFile(string $adapter, string $path, string $file, ?Config $config = null): array
186+
public function storeFile(string $adapter, string $path, string $file, ?Config $config = null): void
202187
{
203188
$config = $this->makeConfigIfNeeded($config);
204-
$result = $this->adapter($adapter)->write($path, (string)file_get_contents($file), $config);
205-
206-
if ($result === false) {
207-
throw new StorageException(sprintf(
208-
'Failed to store file `%s` in `%s` with path `%s`',
209-
$file,
210-
$adapter,
211-
$path,
212-
));
213-
}
214-
215-
return $result;
189+
$this->adapter($adapter)->write($path, (string)file_get_contents($file), $config);
216190
}
217191

218192
/**
@@ -223,17 +197,17 @@ public function storeFile(string $adapter, string $path, string $file, ?Config $
223197
*/
224198
public function fileExists(string $adapter, string $path): bool
225199
{
226-
return $this->adapter($adapter)->has($path);
200+
return $this->adapter($adapter)->fileExists($path);
227201
}
228202

229203
/**
230204
* @param string $adapter Name
231205
* @param string $path File to delete
232206
*
233-
* @return bool
207+
* @return void
234208
*/
235-
public function removeFile(string $adapter, string $path): bool
209+
public function removeFile(string $adapter, string $path): void
236210
{
237-
return $this->adapter($adapter)->delete($path);
211+
$this->adapter($adapter)->delete($path);
238212
}
239213
}

src/StorageServiceInterface.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
namespace PhpCollective\Infrastructure\Storage;
1616

17-
use League\Flysystem\AdapterInterface;
1817
use League\Flysystem\Config;
18+
use League\Flysystem\FilesystemAdapter;
1919

2020
/**
2121
* StorageServiceInterface
@@ -41,9 +41,9 @@ public function adapters(): AdapterCollectionInterface;
4141
*
4242
* @param string $name
4343
*
44-
* @return \League\Flysystem\AdapterInterface
44+
* @return \League\Flysystem\FilesystemAdapter
4545
*/
46-
public function adapter(string $name): AdapterInterface;
46+
public function adapter(string $name): FilesystemAdapter;
4747

4848
/**
4949
* Adds an adapter config
@@ -64,9 +64,9 @@ public function addAdapterConfig(string $name, string $class, array $options);
6464
* @param resource $resource Resource to store
6565
* @param \League\Flysystem\Config|null $config
6666
*
67-
* @return array
67+
* @return void
6868
*/
69-
public function storeResource(string $adapter, string $path, $resource, ?Config $config = null): array;
69+
public function storeResource(string $adapter, string $path, $resource, ?Config $config = null): void;
7070

7171
/**
7272
* Stores a file in a storage backend
@@ -76,9 +76,9 @@ public function storeResource(string $adapter, string $path, $resource, ?Config
7676
* @param string $file File to store
7777
* @param \League\Flysystem\Config|null $config
7878
*
79-
* @return array
79+
* @return void
8080
*/
81-
public function storeFile(string $adapter, string $path, string $file, ?Config $config = null): array;
81+
public function storeFile(string $adapter, string $path, string $file, ?Config $config = null): void;
8282

8383
/**
8484
* Checks if a file exists in a store
@@ -96,7 +96,7 @@ public function fileExists(string $adapter, string $path): bool;
9696
* @param string $adapter Name
9797
* @param string $path File to delete
9898
*
99-
* @return bool
99+
* @return void
100100
*/
101-
public function removeFile(string $adapter, string $path): bool;
101+
public function removeFile(string $adapter, string $path): void;
102102
}

0 commit comments

Comments
 (0)