Selecting an email template and BCC address based on the message type My code-editor "show hints" says that the method length exceeds 20 lines.  How can I refactor the setEmailTemplateBcc function?  

private function setBcc($bcc)
    {
        if ($bcc) {
            $this-&gt;bcc = explode(',', $bcc);
        }
    }


    public function setType($type)
    {
        $this-&gt;setEmailTemplateBcc($type);
        return $this;
    }

    private function setEmailTemplateBcc($type)
    {
        $template = '';
        $bcc = '';

        switch ($type) {
            case self::EMAIL_NEW_SUBSCRIPTION:
                $template = DataHelper::XML_PATH_SUBSCRIPTION_EMAIL;
                $bcc = DataHelper::XML_PATH_REMINDER_EMAIL_BCC;
                break;
            case self::EMAIL_CARD_ADD:
                $template = DataHelper::XML_PATH_NEW_CARD_ADD_EMAIL;
                $bcc = DataHelper::XML_PATH_NEW_CARD_ADD_EMAIL_BCC;
                break;
            case self::EMAIL_PAYMENT_FAILED:
                $template = DataHelper::XML_PATH_PAYMENT_FAILED_EMAIL;
                $bcc = DataHelper::XML_PATH_PAYMENT_FAILED_EMAIL_BCC;
                break;
            case self::EMAIL_PROFILE_UPADATE:
                $template = DataHelper::XML_PATH_PROFILE_UPDATE_EMAIL;
                $bcc = DataHelper::XML_PATH_PROFILE_UPDATE_EMAIL_BCC;
                break;
            case self::EMAIL_REMINDER:
                $template = DataHelper::XML_PATH_REMINDER_EMAIL;
                $bcc = DataHelper::XML_PATH_REMINDER_EMAIL_BCC;
                break;
            case self::EMAIL_TOPUP_REMINDER:
                $template = DataHelper::XML_PATH_EWALLET_TOPUP_REMINDER_EMAIL;
                $bcc = DataHelper::XML_PATH_EWALLET_TOPUP_REMINDER_EMAIL;
                break;
        }

        $this-&gt;setTemplate($template);
        $this-&gt;setBcc($bcc);
    }
I would create two new static variables in your class, arrays that contain all options, like

public static $template = [
    self::EMAIL_NEW_SUBSCRIPTION =&gt; DataHelper::XML_PATH_SUBSCRIPTION_EMAIL,
    self::EMAIL_CARD_ADD         =&gt; DataHelper::XML_PATH_NEW_CARD_ADD_EMAIL_BCC,
    // and so on
];


then setting the email template will be as simple as just one line:

$template = self::$template[self::EMAIL_CARD_ADD] ?? '';


and the same goes for BCC