R
R
roman99662017-04-15 12:29:41
PHP
roman9966, 2017-04-15 12:29:41

Making work with the API of payment systems into traits, is it possible?

There is some kind of service that allows you to change the currency in one payment system to another. Would it be ok to put the logic of working with the payment systems API into traits and then use these traits in the exchange class?

trait PaymentSystem1 {
    ...
}

trait PaymentSystem2 {
    ...
}

trait PaymentSystem3 {
    ...
}

class ExchangerSystem1System2 {
    use PaymentSystem1, PaymentSystem2;
    
    ...
}

class ExchangerSystem1System3 {
    use PaymentSystem1, PaymentSystem3;

    ...
}

class ExchangerSystem2System3 {
    use PaymentSystem2, PaymentSystem3;

    ...
}

Maybe there are some other options? How would you do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Koryukov, 2017-04-15
@MadridianFox

Therefore, payment systems can be called the general concept of "payment systems" because they are designed to perform some similar operations. If you want to be able to replace them or combine them with each other in different combinations, you need to bring them to a common interface, and encapsulate all differences.
Just like that .. and this is a Big Mac)

E
Eugene, 2017-04-15
@Nc_Soft

It seems to me that this is not necessary
ExchangerSystem1System2
ExchangerSystem1System3
ExchangerSystem2System3
I would make 1 Exchanger class, in the constructor of which I would pass two PaymentSystem (also classes)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question