original_string: public function get($directory, $type = self::TYPE_BOTH, $order = self::KEY_NAME, $direction = self::ASC, $limit = null, $fileExtensions = array()) {
          // Get the contents of the dir
          $items     = array();
          $directory = rtrim($directory,'/');
  
          // Check Dir
          if (!is_dir($directory)) {
              throw new \Exception('Directory does not exist: ' . $directory);
          }
  
          // Get Raw Listing
          $directoryHandle = opendir($directory);
          while (false !== ($file = readdir($directoryHandle))) {
              // skip anything that starts with a '.' i.e.:('.', '..', or any hidden file)
              if (substr($file, 0, 1) != '.') {
                  // Directories
                  if (is_dir($directory . '/' . $file) && ($type == self::TYPE_BOTH || $type == self::TYPE_DIR)) {
                      $items[] = array(
                          self::KEY_TYPE => self::TYPE_DIR,
                          self::KEY_NAME => $file,
                          self::KEY_DATE => filemtime($directory.'/'.$file),
                          self::KEY_SIZE => filesize($directory.'/'.$file),
                          self::KEY_EXT  => ''
                      );
  
                  // Files
                  } else if (is_file($directory.'/'.$file) && ($type == self::TYPE_BOTH || $type == self::TYPE_FILE)) {
                      if (!count($fileExtensions) || in_array(self::getExtension($file), $fileExtensions)) {
                          $items[] = array(
                              self::KEY_TYPE => self::TYPE_FILE,
                              self::KEY_NAME => $file,
                              self::KEY_DATE => filemtime($directory.'/'.$file),
                              self::KEY_SIZE => filesize($directory.'/'.$file),
                              self::KEY_EXT  => self::getExtension($file)
                          );
                      }
                  }
              }
  
              // Impose Limit, if specified
              if ($limit && count($items) >= $limit) {
                  break;
              }
          }
  
          closedir($directoryHandle);
  
          // Sorting
          $items = $this->sort($items, $type, $order, $direction);
  
          // Callbacks
          if ($this->filterCallback) {
              $items = call_user_func($this->filterCallback, $items);
          }
  
          // Total Size
          $totalSize = 0;
          foreach ($items as $item) {
              $totalSize += $item[self::KEY_SIZE];
          }
  
          $this->lastSize = $totalSize;
          $this->lastItemCount = count($items);
  
          return $items;
      }
code: public function get($directory, $type = self::TYPE_BOTH, $order = self::KEY_NAME, $direction = self::ASC, $limit = null, $fileExtensions = array()) {
          // Get the contents of the dir
          $items     = array();
          $directory = rtrim($directory,'/');
  
          // Check Dir
          if (!is_dir($directory)) {
              throw new \Exception('Directory does not exist: ' . $directory);
          }
  
          // Get Raw Listing
          $directoryHandle = opendir($directory);
          while (false !== ($file = readdir($directoryHandle))) {
              // skip anything that starts with a '.' i.e.:('.', '..', or any hidden file)
              if (substr($file, 0, 1) != '.') {
                  // Directories
                  if (is_dir($directory . '/' . $file) && ($type == self::TYPE_BOTH || $type == self::TYPE_DIR)) {
                      $items[] = array(
                          self::KEY_TYPE => self::TYPE_DIR,
                          self::KEY_NAME => $file,
                          self::KEY_DATE => filemtime($directory.'/'.$file),
                          self::KEY_SIZE => filesize($directory.'/'.$file),
                          self::KEY_EXT  => ''
                      );
  
                  // Files
                  } else if (is_file($directory.'/'.$file) && ($type == self::TYPE_BOTH || $type == self::TYPE_FILE)) {
                      if (!count($fileExtensions) || in_array(self::getExtension($file), $fileExtensions)) {
                          $items[] = array(
                              self::KEY_TYPE => self::TYPE_FILE,
                              self::KEY_NAME => $file,
                              self::KEY_DATE => filemtime($directory.'/'.$file),
                              self::KEY_SIZE => filesize($directory.'/'.$file),
                              self::KEY_EXT  => self::getExtension($file)
                          );
                      }
                  }
              }
  
              // Impose Limit, if specified
              if ($limit && count($items) >= $limit) {
                  break;
              }
          }
  
          closedir($directoryHandle);
  
          // Sorting
          $items = $this->sort($items, $type, $order, $direction);
  
          // Callbacks
          if ($this->filterCallback) {
              $items = call_user_func($this->filterCallback, $items);
          }
  
          // Total Size
          $totalSize = 0;
          foreach ($items as $item) {
              $totalSize += $item[self::KEY_SIZE];
          }
  
          $this->lastSize = $totalSize;
          $this->lastItemCount = count($items);
  
          return $items;
      }
code_tokens: public function get ( $ directory , $ type = self :: TYPE_BOTH , $ order = self :: KEY_NAME , $ direction = self :: ASC , $ limit = null , $ fileExtensions = array ( ) ) { // Get the contents of the dir $ items = array ( ) ; $ directory = rtrim ( $ directory , '/' ) ; // Check Dir if ( ! is_dir ( $ directory ) ) { throw new \ Exception ( 'Directory does not exist: ' . $ directory ) ; } // Get Raw Listing $ directoryHandle = opendir ( $ directory ) ; while ( false !== ( $ file = readdir ( $ directoryHandle ) ) ) { // skip anything that starts with a '.' i.e.:('.', '..', or any hidden file) if ( substr ( $ file , 0 , 1 ) != '.' ) { // Directories if ( is_dir ( $ directory . '/' . $ file ) && ( $ type == self :: TYPE_BOTH || $ type == self :: TYPE_DIR ) ) { $ items [ ] = array ( self :: KEY_TYPE => self :: TYPE_DIR , self :: KEY_NAME => $ file , self :: KEY_DATE => filemtime ( $ directory . '/' . $ file ) , self :: KEY_SIZE => filesize ( $ directory . '/' . $ file ) , self :: KEY_EXT => '' ) ; // Files } else if ( is_file ( $ directory . '/' . $ file ) && ( $ type == self :: TYPE_BOTH || $ type == self :: TYPE_FILE ) ) { if ( ! count ( $ fileExtensions ) || in_array ( self :: getExtension ( $ file ) , $ fileExtensions ) ) { $ items [ ] = array ( self :: KEY_TYPE => self :: TYPE_FILE , self :: KEY_NAME => $ file , self :: KEY_DATE => filemtime ( $ directory . '/' . $ file ) , self :: KEY_SIZE => filesize ( $ directory . '/' . $ file ) , self :: KEY_EXT => self :: getExtension ( $ file ) ) ; } } } // Impose Limit, if specified if ( $ limit && count ( $ items ) >= $ limit ) { break ; } } closedir ( $ directoryHandle ) ; // Sorting $ items = $ this -> sort ( $ items , $ type , $ order , $ direction ) ; // Callbacks if ( $ this -> filterCallback ) { $ items = call_user_func ( $ this -> filterCallback , $ items ) ; } // Total Size $ totalSize = 0 ; foreach ( $ items as $ item ) { $ totalSize += $ item [ self :: KEY_SIZE ] ; } $ this -> lastSize = $ totalSize ; $ this -> lastItemCount = count ( $ items ) ; return $ items ; }
docstring: Return the listing of a directory
  
  @param  string $directory
  @param  string $type
  @param  string $order
  @param  string $direction
  @param  int    $limit
  @param  array  $fileExtensions
  @return array
  @throws \Exception
docstring_tokens: Return the listing of a directory