23
23
use League \Flysystem \Visibility ;
24
24
use League \MimeTypeDetection \FinfoMimeTypeDetector ;
25
25
use RuntimeException ;
26
+ use TypeError ;
26
27
27
28
class BunnyCDNAdapter implements FilesystemAdapter
28
29
{
@@ -280,6 +281,8 @@ public function visibility(string $path): FileAttributes
280
281
return new FileAttributes ($ this ->getObject ($ path )->path (), null , $ this ->pullzone_url ? 'public ' : 'private ' );
281
282
} catch (UnableToReadFile $ e ) {
282
283
throw new UnableToRetrieveMetadata ($ e ->getMessage ());
284
+ } catch (TypeError $ e ) {
285
+ throw new UnableToRetrieveMetadata ('Cannot retrieve visibility of folder ' );
283
286
}
284
287
}
285
288
@@ -296,8 +299,8 @@ public function mimeType(string $path): FileAttributes
296
299
try {
297
300
$ object = $ this ->getObject ($ path );
298
301
299
- if ($ object instanceof DirectoryAttributes) {
300
- throw new UnableToRetrieveMetadata ( ' Cannot retrieve mimetype of folder ' );
302
+ if ($ object instanceof DirectoryAttributes) {
303
+ throw new TypeError ( );
301
304
}
302
305
303
306
/** @var FileAttributes $object */
@@ -320,6 +323,8 @@ public function mimeType(string $path): FileAttributes
320
323
return $ object ;
321
324
} catch (UnableToReadFile $ e ) {
322
325
throw new UnableToRetrieveMetadata ($ e ->getMessage ());
326
+ } catch (TypeError $ e ) {
327
+ throw new UnableToRetrieveMetadata ('Cannot retrieve mimeType of folder ' );
323
328
}
324
329
}
325
330
@@ -356,6 +361,8 @@ public function lastModified(string $path): FileAttributes
356
361
return $ this ->getObject ($ path );
357
362
} catch (UnableToReadFile $ e ) {
358
363
throw new UnableToRetrieveMetadata ($ e ->getMessage ());
364
+ } catch (TypeError $ e ) {
365
+ throw new UnableToRetrieveMetadata ('Last Modified only accepts files as parameters, not directories ' );
359
366
}
360
367
}
361
368
@@ -366,17 +373,11 @@ public function lastModified(string $path): FileAttributes
366
373
public function fileSize (string $ path ): FileAttributes
367
374
{
368
375
try {
369
- $ object = $ this ->getObject ($ path );
370
-
371
- if ($ object instanceof DirectoryAttributes) {
372
- // @codeCoverageIgnoreStart
373
- throw new UnableToRetrieveMetadata ('Cannot retrieve size of folder ' );
374
- // @codeCoverageIgnoreEnd
375
- }
376
-
377
- return $ object ;
376
+ return $ this ->getObject ($ path );
378
377
} catch (UnableToReadFile $ e ) {
379
378
throw new UnableToRetrieveMetadata ($ e ->getMessage ());
379
+ } catch (TypeError $ e ) {
380
+ throw new UnableToRetrieveMetadata ('Cannot retrieve size of folder ' );
380
381
}
381
382
}
382
383
0 commit comments