PHP refactoring: function aliases? Need opinions.

Posted 1 year 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.

Reply to

Use Markdown with GitHub-flavored code blocks.