1414
1515namespace PhpCollective \Infrastructure \Storage ;
1616
17- use League \Flysystem \AdapterInterface ;
1817use League \Flysystem \Config ;
19- use PhpCollective \ Infrastructure \ Storage \ Exception \ StorageException ;
18+ use League \ Flysystem \ FilesystemAdapter ;
2019use PhpCollective \Infrastructure \Storage \Factories \Exception \FactoryNotFoundException ;
2120use 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}
0 commit comments