Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
123 stars 134 forks source link

Added constant classes to improve clarity, avoid typos and be informed of possible values #573

Open garsaud opened 2 years ago

garsaud commented 2 years ago

I added a few more classes with constant values, so instead of writing this :

$draftCardRegistration = new CardRegistration();
$draftCardRegistration->Currency = CurrencyIso::EUR; // ← constant already existed for this one
$draftCardRegistration->CardType = 'CB_VISA_MASTERCARD'; // ← but not for that one

we can use the dedicated constants :

$cardRegistration = new CardRegistration();
$cardRegistration->Currency = CurrencyIso::EUR;
$cardRegistration->CardType = CardType::CbVisaMastercard;

This will avoid keeping hardcoded values in the logic, avoid risks of typographical error, and improve clarity by showing the possible values for a parameter.

I used the official documentation, which often gives types and possible values, although those types didn’t exist yet in the SDK:

Official documentation showing ‘CardType’ and ‘CurrencyIso’, which don’t accually exist yet
garsaud commented 1 year ago

@iulian03 Hi! Is it possible to merge this PR?

psociety commented 1 year ago

@iulian03 ping