Skip to content

artkonekt/xtend

Repository files navigation

Plugin Features for PHP

Tests Packagist version Packagist downloads StyleCI MIT Software License

Requirements

  • PHP 8.2+

Features

  • Registries
  • Hooks

Installation

You can install the package via composer:

composer require konekt/xtend

Usage

Registries

The following example shows a sample registry that holds reference to various PaymentGateway implementations.

Steps:

  1. Create a class
  2. Add the Registry interface
  3. Use the HasRegistry and RequiresClassOrInterface traits
  4. Add the $requiredInterface static 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);