thiagobarros2/file-counter

A simple way to test how many files are into a given dir based on extension
8,262
Install
composer require thiagobarros2/file-counter
Latest Version:v1.3.0
PHP:^8.2
License:MIT
Last Updated:Feb 3, 2024
Links: GitHub  ·  Packagist
Maintainer: thiagobarros2

Instalation

# development
$ composer require thiagobarros2/file-counter --dev

# production
$ composer require thiagobarros2/file-counter

# warning: this package can be of course used in production but was thought to be a dev-dependency

Usage

<?php

namespace src;

use ThiagoBarros\FileCounter\Counter;

function yourFunction() {
    $number_of_files = Counter::number_of_files('path_to_dir', 'file_extension'); //the file_extension param can be provided with or without '.'    
    return $number_of_files;
});

<?php

namespace src;

use ThiagoBarros\FileCounter\Lister;

function yourFunction() {
    $files_by_extension = Lister::files_by_extension('path_to_dir');     
    return $files_by_extension;
});