@@ -478,7 +478,7 @@ public function delete($path): void
478
478
*/
479
479
public function directoryExists (string $ path ): bool
480
480
{
481
- return $ this ->fileExists ( $ path );
481
+ return $ this ->exists (StorageAttributes:: TYPE_DIRECTORY , $ path );
482
482
}
483
483
484
484
/**
@@ -487,16 +487,7 @@ public function directoryExists(string $path): bool
487
487
*/
488
488
public function fileExists (string $ path ): bool
489
489
{
490
- $ list = new DirectoryListing ($ this ->listContents (
491
- Util::splitPathIntoDirectoryAndFile ($ path )['dir ' ],
492
- false
493
- ));
494
-
495
- $ count = $ list ->filter (function (StorageAttributes $ item ) use ($ path ) {
496
- return Util::normalizePath ($ item ->path ()) === Util::normalizePath ($ path );
497
- })->toArray ();
498
-
499
- return (bool ) count ($ count );
490
+ return $ this ->exists (StorageAttributes::TYPE_FILE , $ path );
500
491
}
501
492
502
493
/**
@@ -559,4 +550,18 @@ private static function parse_bunny_timestamp(string $timestamp): int
559
550
{
560
551
return (date_create_from_format ('Y-m-d\TH:i:s.u ' , $ timestamp ) ?: date_create_from_format ('Y-m-d\TH:i:s ' , $ timestamp ))->getTimestamp ();
561
552
}
553
+
554
+ private function exists (string $ type , string $ path ): bool
555
+ {
556
+ $ list = new DirectoryListing ($ this ->listContents (
557
+ Util::splitPathIntoDirectoryAndFile ($ path )['dir ' ],
558
+ false
559
+ ));
560
+
561
+ $ count = $ list ->filter (function (StorageAttributes $ item ) use ($ path , $ type ) {
562
+ return $ item ->type () === $ type && Util::normalizePath ($ item ->path ()) === Util::normalizePath ($ path );
563
+ })->toArray ();
564
+
565
+ return (bool ) count ($ count );
566
+ }
562
567
}
0 commit comments