mardi 21 juin 2016

Using a method for different non related tasks

So I stumbled upon the question - can it be considered as a bad practice or an anti-pattern to use a method that initially was meant to serve different purpose?

For example, an error handling package had a static method for checking if it is an AJAX request or isn't. Afterwards, I decided to use the method in non-throwable related tasks.

public static function ajax()
{
    //check $_SERVER['HTTP_X_REQUESTED_WITH']
}
...
public function myMethod()
{
     $ajax = ThrowableHandlerMethod::ajax();

     if ($ajax) {
         echo 'foo, bar';
     }
}

Aucun commentaire:

Enregistrer un commentaire