original_string: public function files($directory, $recursive = false)
      {
          $result     = [];
          $recursive  = boolval($recursive);
  
          if ( ! $this->isDirectory($directory)) return [];
  
          $items = new FilesystemIterator($directory);
  
          foreach ($items as $item) {
              if ($item->isFile()) {
                  $result[]       = $item->getPathname();
              } elseif ($recursive && $item->isDir() && ! $item->isLink()) {
                  $subFiles       = $this->files($item->getPathname(), $recursive);
                  foreach ($subFiles as $file) {
                      $result[]   = $file;
                  }
              }
          }
  
          return $result;
      }
code: public function files($directory, $recursive = false)
      {
          $result     = [];
          $recursive  = boolval($recursive);
  
          if ( ! $this->isDirectory($directory)) return [];
  
          $items = new FilesystemIterator($directory);
  
          foreach ($items as $item) {
              if ($item->isFile()) {
                  $result[]       = $item->getPathname();
              } elseif ($recursive && $item->isDir() && ! $item->isLink()) {
                  $subFiles       = $this->files($item->getPathname(), $recursive);
                  foreach ($subFiles as $file) {
                      $result[]   = $file;
                  }
              }
          }
  
          return $result;
      }
code_tokens: public function files ( $ directory , $ recursive = false ) { $ result = [ ] ; $ recursive = boolval ( $ recursive ) ; if ( ! $ this -> isDirectory ( $ directory ) ) return [ ] ; $ items = new FilesystemIterator ( $ directory ) ; foreach ( $ items as $ item ) { if ( $ item -> isFile ( ) ) { $ result [ ] = $ item -> getPathname ( ) ; } elseif ( $ recursive && $ item -> isDir ( ) && ! $ item -> isLink ( ) ) { $ subFiles = $ this -> files ( $ item -> getPathname ( ) , $ recursive ) ; foreach ( $ subFiles as $ file ) { $ result [ ] = $ file ; } } } return $ result ; }
docstring: get all files in directory
  
  @param string $directory
  @param bool $recursive
  @return array
docstring_tokens: get all files in directory