isDirectory() public method

Check if key is a directory
Requires '\Webiny\Component\Storage\Driver\DirectoryAwareInterface' to be implemented by a Driver class
public isDirectory ( string $key ) : boolean
$key string
return boolean
Example #1
0
 /**
  * Construct a File instance
  *
  * @param string  $key     File key
  * @param Storage $storage Storage to use
  *
  * @throws \Webiny\Component\Storage\StorageException
  * @return \Webiny\Component\Storage\File\File
  */
 public function __construct($key, Storage $storage)
 {
     $this->storage = $storage;
     $this->key = $key;
     // Make sure a file path is given
     if ($this->storage->keyExists($key) && $this->storage->isDirectory($this->key)) {
         throw new StorageException(StorageException::FILE_OBJECT_CAN_NOT_READ_DIRECTORY_PATHS, [$key]);
     }
 }