code: private function getDirContents($dir, &$results = [])
      {
          $files = scandir($dir);
  
          foreach ($files as $value) {
              $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
              if (!is_dir($path)) {
                  $results[] = $path;
                  continue;
              }
  
              if ($value != '.' && $value != '..') {
                  $this->getDirContents($path, $results);
                  $results[] = $path;
              }
          }
  
          return $results;
      }
docs: Get the contents of the selected directory and return an array of the listing.
  
  @param string $dir
  @param array  $results
  
  @return array