code: protected function scanDir($dir)
      {
          $result = array();
          $list = $this->scanDirExec($dir);
  
          foreach ($list as $element) {
              $elementPath = $dir . DIRECTORY_SEPARATOR . $element;
  
              if (is_file($elementPath)) {
                  $fileInfo = pathinfo($element);
                  if (in_array($fileInfo['extension'], $this->getAllowedFileExtensions())) {
                      $result[] = $this->getNameSpace() . "\\" . $fileInfo['filename'];
                  }
              }
          }
          return $result;
      }
docs: method to scan directory
  
  @param string $dir dir to scan
  
  @return array