How do I concatenate a variable in a class with a static function?

1

I have a problem, I have a function that, when I pass the card number, returns the name of the flag (visa, mastercard etc)

And I need to return the flag name inside a static function

 $bandeira = getBandeiraByNumber("55523131232131"); retorna string visa
 $card->setCreditCardBrand(\Gateway\One\DataContract\Enum\CreditCardBrandEnum::$bandeira);

Here's the move

CreditCardBrandEnum::$bandeira

It returns this error

Fatal error: Access to undeclared static property: Gateway\One\DataContract\Enum\CreditCardBrandEnum::$bandeira in /var/www/html/exec/mundipagg/Mundipagg.php on line 148

Abstract class is like this.

Gateway \ One \ DataContract \ Enum; namespace

abstract class CreditCardBrandEnum
{
    const VISA = 'Visa';
    const MASTERCARD = 'Mastercard';
    const HIPERCARD = 'Hipercard';
    const AMEX = 'Amex';
    const DINERS = 'Diners';
    const ELO = 'Elo';
    const AURA = 'Aura';
    const DISCOVER = 'Discover';
    const CASASHOW = 'CasaShow';
    const HAVAN = 'Havan';
    const HUGCARD = 'HugCard';
    const ANDARAKI = 'AndarAki';
    const LEADERCARD = 'LearderCard';
}

In case I want to transform a variable into const static, but I'm not getting it.

    
asked by anonymous 09.05.2016 / 19:31

1 answer

2

You need to pass the correct value to access the constant, in case visa is low when it should be in the uppercase, use a function to leave the return in capital letters as strtoupper() or mb_convert_case() for characters with multibyte encode .

$bandeira = strtoupper(getBandeiraByNumber("55523131232131"));
$card->setCreditCardBrand($bandeira);

or

$bandeira = mb_convert_case(getBandeiraByNumber("55523131232131"), MB_CASE_UPPER);
    
09.05.2016 / 19:40