Helper Functions

Introduction

TODO

Available Methods

Method listing

alert()

alert()->info('This is my info message');

entity()

return entity(WebsitesEntity::class, 'index')
    ->setQuery(Website::all())
    ->render();

get_traits()

Get the traits used on a certain class.

// Loop over the MyClass traits using a generator.
foreach (get_traits(MyClass::class) as $namespace) {
    // MyNamespace\AwesomeTrait
}

has_trait()

Check if a given trait exists on a given instance.

if (has_trait(MyClass::class, MyNamespace\AwesomeTrait::class)) {
    // Yes I have this trait.
}

module_path()

try_method()

Test the existance of a certain class method and try calling the method when it does exist.

// aMethod() will be called on $myInstance when the method
// exists and will be passed the 'several' and
// 'options' variables.
try_method($myInstance, 'aMethod', [
    'several', 'options',
]);