public function withToken(Token $token)
    {
        $card = $this->with('token', $token);

        if (null !== $card->number) {
            $lastDigits = strlen($card->number) <= 4
                ? $card->number :
                substr($card->number, -4);
            $card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
        }

        $card->cvv = null;

        return $card;
    }
public function withToken(Token $token)
    {
        $card = $this->with('token', $token);

        if (null !== $card->number) {
            $lastDigits = strlen($card->number) <= 4
                ? $card->number :
                substr($card->number, -4);
            $card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
        }

        $card->cvv = null;

        return $card;
    }
public function withToken ( Token $ token ) { $ card = $ this -> with ( 'token' , $ token ) ; if ( null !== $ card -> number ) { $ lastDigits = strlen ( $ card -> number ) <= 4 ? $ card -> number : substr ( $ card -> number , - 4 ) ; $ card -> number = "XXXX-XXXX-XXXX-" . $ lastDigits ; } $ card -> cvv = null ; return $ card ; }
Sets token value.

@param  Token $token
@return CreditCard
Sets token value .