protected function isEmptyDirectory($dir) { // glob() cannot be used because it doesn't take into account hidden files // scandir() returns '.' and '..' for an empty dir return 2 === count(scandir($dir . '/')); }