Mmoreram\PHPFormatter\Finder\FileFinder::findPHPFilesByPath PHP Method

findPHPFilesByPath() public method

Find all php files by path.
public findPHPFilesByPath ( string $path ) : Finder
$path string Path
return Symfony\Component\Finder\Finder Finder iterable object with all PHP found files in path
    public function findPHPFilesByPath($path)
    {
        $finder = new Finder();
        if (file_exists($path) && !is_dir($path)) {
            $finder->append([0 => $path]);
        } else {
            $finder->files()->in($path)->name('*.php');
        }
        return $finder;
    }

Usage Example

 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return int|null|void
  *
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     /**
      * We load the options to work with
      */
     $options = $this->getUsableConfig($input);
     /**
      * Building the real directory or file to work in
      */
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($path)) {
         $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     }
     if (!is_file($path) && !is_dir($path)) {
         throw new Exception('Directory or file "' . $path . '" does not exist');
     }
     /**
      * Print dry-run message if needed
      */
     $this->printDryRunMessage($input, $output, $path);
     /**
      * Print all configuration block if verbose level allows it
      */
     $this->printConfigUsed($output, $options);
     $fileFinder = new FileFinder();
     $files = $fileFinder->findPHPFilesByPath($path);
     /**
      * Parse and fix all found files
      */
     $this->parseAndFixFiles($input, $output, $files, $options);
 }
All Usage Examples Of Mmoreram\PHPFormatter\Finder\FileFinder::findPHPFilesByPath