dimanche 4 décembre 2016

Explicit variable declaration when using extract()

I have the following snippet:

protected function sendEmail($email)
{
    extract($email);

    $this->transmail->locale($locale)
                    ->timezone($timezone)
                    ->template($template)
                    ->subject($subject)
                    ->send($header, $params);
}

This code works perfectly (full source code here). However, I want to make sure to follow some good practices on the go. I'm currenlty getting [some CodeClimate warnings] (PHPMD)(http://ift.tt/2gow25C):

  • Avoid unused local variables such as '$locale'.
  • Avoid unused local variables such as '$timezone'.
  • Avoid unused local variables such as '$template'.
  • Avoid unused local variables such as '$subject'.
  • Avoid unused local variables such as '$header'.
  • Avoid unused local variables such as '$params'.

Which would be elegant ways to go about it?

Should I explicitly declare the variables with list() or something like such?

Thanks in advance



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gCBipc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire