Return error messages for sending emails How can I optimize this piece of code and avoid the multiple if/else call for returning error message ?

    if ($cardStatus == true) {

        $cardEmailContent = $this-&gt;setCardEmailContent();
        $sendUserEmail    = $this-&gt;sendCardToUser($cardEmailContent);

        if ($sendUserEmail) { 
            $this-&gt;sendAdminEmail();
            $this-&gt;updateCardDetails();
        } else {
            return $sendUserEmail;
        }

    } else {
        return $this-&gt;cardApiError;
    }
By switching the if condition to check if $cardStatus is false and the same for $sendUserEmail you will reduce some of the nesting.  

if (!$cardStatus) {
    return $this-&gt;cardApiError;
}

$cardEmailContent = $this-&gt;setCardEmailContent();
$sendUserEmail    = $this-&gt;sendCardToUser($cardEmailContent);

if (!$sendUserEmail) { 
    return $sendUserEmail;
}

$this-&gt;sendAdminEmail();
$this-&gt;updateCardDetails();


by using these guard clauses it avoids the upcoming arrow antipattern.