
Tech
Tired of "new" Everywhere? Learn Factory Method with Laravel
1. Hook & Problem Statement
You're building a Laravel application. You need to create a payment processor. So you write:
$processor = new StripePaymentProcessor (
config ( 'services.stripe.secret' ),
config ( 'services.stripe.webhook_secret' )
);
Then you need to create a different processor for another part of the system:
$processor = new PayPalPaymentProcessor (
config ( 'services.paypal.client_id' ),
config ...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to