degraciamathieu/php-file-explorer

v0.4.1 2023-02-22 19:42 UTC

This package is auto-updated.

Last update: 2024-10-22 23:01:54 UTC


README

PHP Composer packagist packagist

php-file-explorer

Code originally taken from bmitch/churn-php

composer require degraciamathieu/php-file-explorer

Usage

use DeGraciaMathieu\FileExplorer\FileFinder;

$fileFinder = new FileFinder(
    basePath: __DIR__,
);

$files = $fileFinder->getFiles();

foreach ($files as $file) {

   # DeGraciaMathieu\FileExplorer\File
   $file->fullPath;
   $file->displayPath;
}
$fileFinder = new FileFinder(
    basePath: 'app/Modules/', 
    onlyPatterns: [
        '.*/Logics/.*',
        '.*Logic.php',
    ],
);

$files = $fileFinder->getFiles();
$fileFinder = new FileFinder(
    basePath: 'app/Modules/', 
    ignorePatterns: [
        '.*/Repositories/.*',
    ],
);

$files = $fileFinder->getFiles();
$fileFinder = new FileFinder(
    basePath: 'app/', 
);

$files = $fileFinder->getFiles([
    'Models/.*',
    'Services/.*',
]);

Tests

make test
make coverage