- PHP 8.2+
- Registries
- Hooks
You can install the package via composer:
composer require konekt/xtendThe following example shows a sample registry that holds reference to various PaymentGateway implementations.
Steps:
- Create a class
- Add the
Registryinterface - Use the
HasRegistryandRequiresClassOrInterfacetraits - Add the
$requiredInterfacestatic property, and set the interface
final class PaymentGateways implements Registry
{
use HasRegistry;
use RequiresClassOrInterface;
private static string $requiredInterface = PaymentGateway::class;
}Having that, other developers can add new payment gateways:
PaymentGateways::add('braintree', BrainTreePaymentGateway::class);