public function isDir(string $dir) : bool
{
// Asking random server
$response = $this->sendRequest($this->getDirPath($dir), self::METHOD_PROPFIND, ['Depth' => '0']);
// The directory does not exist or server does not support PROPFIND method
if (self::STATUS_207_MULTI_STATUS !== $response->getStatusCode()) {
return false;
}
// Fetches properties from the server
$properties = $this->getProperties($response);
// Checks if it is a directory
return isset($properties['getcontenttype']) && 'httpd/unix-directory' === $properties['getcontenttype'];
}