daikazu/misc-helpers

Misc PHP and Laravel helper functions and Classes
1,703
Install
composer require daikazu/misc-helpers
Latest Version:v1.3.0
PHP:^8.3
License:MIT
Last Updated:Mar 18, 2026
Links: GitHub  ·  Packagist
Maintainer: daikazu

Misc PHP and Laravel helper functions and Classes

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a collection of helper functions and classes for PHP and Laravel.

Installation

You can install the package via composer:

composer require daikazu/misc-helpers

Usage

Helper Functions

format_business_hours

Formats business hours into a human-readable string.

$hours = [
    'monday' => ['open' => '09:00', 'close' => '17:00'],
    'tuesday' => ['open' => '09:00', 'close' => '17:00'],
    'wednesday' => ['open' => '09:00', 'close' => '17:00']
];

$formatted = format_business_hours($hours, 'America/New_York');
echo $formatted; // Outputs: Monday - Wednesday 9am-5pm EDT
calculate_read_time

Calculates the estimated read time for a given HTML content.

$content = '<p>This is a very short text.</p>';
$readTime = calculate_read_time($content);
echo $readTime; // Outputs: 1
is_blade_section_empty

Checks if a Blade section is empty.

@section('test')
    <p>Section is empty</p>
@endsection
$isEmpty = is_blade_section_empty('test');
var_dump($isEmpty); // Outputs: bool(false)
generate_initials

Generates initials from a given name.

$name = 'John Doe';
$initials = generate_initials($name);
echo $initials; // Outputs: JD
clean_string

Cleans a string by removing extra whitespace and optionally converting it to lowercase.

$string = '   Hello    World   ';
$cleaned = clean_string($string);
echo $cleaned; // Outputs: Hello World

Artisan Commands

PruneLogFilesCommand

The PruneLogFilesCommand is a custom Artisan command used to prune old log files from the storage directory.

Usage

To run the command, use the following Artisan command:

php artisan log:prune

Options

  • --days[=DAYS]: The number of days to retain log files. Files older than this will be deleted. Default is 30 days.

Example

To prune log files older than 15 days, run:

php artisan log:prune --days=15

Utility Classes

PhpArrayFormatter

The PhpArrayFormatter class provides functionality to format PHP arrays into a readable string representation.

####Usage To use the PhpArrayFormatter, you can create an instance of the class and call the format method with the array you want to format.

use App\Utilities\PhpArrayFormatter;

$array = [
    'name' => 'John Doe',
    'email' => 'john.doe@example.com',
    'roles' => ['admin', 'user']
];

$formatter = new PhpArrayFormatter();
$formattedArray = $formatter->format($array);

echo $formattedArray;
// Outputs:
// [
//     'name' => 'John Doe',
//     'email' => 'john.doe@example.com',
//     'roles' => [
//         'admin',
//         'user'
//     ]
// ]

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

daikazu/filament-image-checkbox-group

Image-based checkbox group component for FilamentPHP

4,744 4
daikazu/filament-lightbox

This is my package filament-lightbox

2,299 2
daikazu/eloquent-salesforce-objects

A Laravel package that provides an Eloquent-style interface for interacting with...

11,349 10
daikazu/laravel-glider

Start using Glide on-the-fly instantly in your Laravel blade templates.

9,658 93
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700

Version History

Version Released PHP Laravel License
v1.3.0 ^8.3 >=11.0 MIT
v1.2.0 ^8.3 ^11.0||^12.0 MIT
v1.1.1 ^8.2 ^11.0||^12.0 MIT
v1.1.0 ^8.2 ^11.0 MIT
v1.0.1 ^8.2 ^11.0 MIT