PHP refactoring: function aliases? Need opinions.

Posted 8 months ago by godbout

Wondering if there's a way to avoid the duplication of a couple of helper functions I did for my tests:

function birth($action, $arguments)
{
    ...
}

function raw()
{
    return birth(__FUNCTION__, func_get_args());
}

function make()
{
    return birth(__FUNCTION__, func_get_args());
}

function create()
{
    return birth(__FUNCTION__, func_get_args());
}

birth is where everything happens obviously. I'm pretty sure I don't know PHP enough and there's a better way rather than copypasting each function. It doesn't really matter per se, but I'm curious. Any thoughts?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.