for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\CollectionMacros;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class CollectionMacroServiceProvider extends ServiceProvider
{
public function register()
Collection::make(glob(__DIR__.'/Macros/*.php'))
->mapWithKeys(function ($path) {
return [$path => pathinfo($path, PATHINFO_FILENAME)];
})
->reject(function ($macro) {
return Collection::hasMacro($macro);
->each(function ($macro, $path) {
$path
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$class = 'Spatie\\CollectionMacros\\Macros\\'.$macro;
$macro = Str::camel($macro);
if($macro === 'tryCatch') {
$macro = 'try';
}
Collection::macro($macro, app($class)());
});
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.