Simple problems require simple solutions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
529 B

<?php
namespace App\Traits;
trait Invokable
{
/**
* Invoke the given service.
*
* @see __invoke()
*/
public static function invoke(...$arguments)
{
return app(static::class)(...$arguments);
}
/**
* Invoke the given service if the boolean argument is truthy.
*
* @see __invoke()
*/
public static function invokeIf($boolean, ...$arguments)
{
if (!$boolean) {
return;
}
return static::invoke(...$arguments);
}
}