code: protected function listSubDirs($dir)
      {
          $list = [];
          $handle = opendir($dir);
          if ($handle === false) {
              throw new InvalidParamException("Unable to open directory: $dir");
          }
          while (($file = readdir($handle)) !== false) {
              if ($file === '.' || $file === '..') {
                  continue;
              }
              // ignore hidden directories
              if ($file[0] === '.') {
                  continue;
              }
              if (is_dir("$dir/$file")) {
                  $list[] = "$dir/$file";
              }
          }
          closedir($handle);
          return $list;
      }
docs: Get a list of subdirectories for directory specified.
  @param string $dir directory to read
  
  @return array list of subdirectories