This package provides a collection of helper functions and classes for PHP and Laravel.
You can install the package via composer:
composer require daikazu/misc-helpers
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
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
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)
Generates initials from a given name.
$name = 'John Doe';
$initials = generate_initials($name);
echo $initials; // Outputs: JD
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
The PruneLogFilesCommand
is a custom Artisan command used to prune old log files from the storage directory.
To run the command, use the following Artisan command:
php artisan log:prune
--days[=DAYS]
: The number of days to retain log files. Files older than this will be deleted. Default is 30 days.
To prune log files older than 15 days, run:
php artisan log:prune --days=15
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'
// ]
// ]
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.