| @@ -1,49 +1,49 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace Booktics\Payment; | |
| 4 | - | |
| 5 | -use Booktics\Payment\Contracts\Payment_Method_Interface; | |
| 6 | -use WP_Error; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * Manager for payment methods. | |
| 10 | - * | |
| 11 | - * Allows registering and retrieving payment methods. Also handles processing | |
| 12 | - * payments using a specified payment method. | |
| 13 | - * | |
| 14 | - * @package Booktics\Core\Payment | |
| 15 | - * @since 1.0.0 | |
| 16 | - */ | |
| 17 | -class Payment_Method_Manager { | |
| 18 | - | |
| 19 | - private $payment_methods = array(); | |
| 20 | - | |
| 21 | - public function __construct() { | |
| 22 | - $this->payment_methods = apply_filters( 'booktics_payment_methods', array() ); | |
| 23 | - } | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * Get all registered payment methods | |
| 27 | - * | |
| 28 | - * @return array | |
| 29 | - */ | |
| 30 | - public function get_payment_methods(): array { | |
| 31 | - return apply_filters( 'booktics_payment_methods', $this->payment_methods ); | |
| 32 | - } | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * Get a payment method by its ID | |
| 36 | - * | |
| 37 | - * @param string $id | |
| 38 | - * | |
| 39 | - * @return Payment_Method_Interface|null Returns the payment method instance or null if not found | |
| 40 | - */ | |
| 41 | - public function get_payment_method( string $id ): ?Payment_Method_Interface { | |
| 42 | - $payment_methods = $this->get_payment_methods(); | |
| 43 | - if ( ! isset( $payment_methods[ $id ] ) ) { | |
| 44 | - return null; | |
| 45 | - } | |
| 46 | - | |
| 47 | - return new $payment_methods[ $id ](); | |
| 48 | - } | |
| 49 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace Booktics\Payment; | |
| 4 | + | |
| 5 | +use Booktics\Payment\Contracts\Payment_Method_Interface; | |
| 6 | +use WP_Error; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Manager for payment methods. | |
| 10 | + * | |
| 11 | + * Allows registering and retrieving payment methods. Also handles processing | |
| 12 | + * payments using a specified payment method. | |
| 13 | + * | |
| 14 | + * @package Booktics\Core\Payment | |
| 15 | + * @since 1.0.0 | |
| 16 | + */ | |
| 17 | +class Payment_Method_Manager { | |
| 18 | + | |
| 19 | + private $payment_methods = array(); | |
| 20 | + | |
| 21 | + public function __construct() { | |
| 22 | + $this->payment_methods = apply_filters( 'booktics_payment_methods', array() ); | |
| 23 | + } | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * Get all registered payment methods | |
| 27 | + * | |
| 28 | + * @return array | |
| 29 | + */ | |
| 30 | + public function get_payment_methods(): array { | |
| 31 | + return apply_filters( 'booktics_payment_methods', $this->payment_methods ); | |
| 32 | + } | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Get a payment method by its ID | |
| 36 | + * | |
| 37 | + * @param string $id | |
| 38 | + * | |
| 39 | + * @return Payment_Method_Interface|null Returns the payment method instance or null if not found | |
| 40 | + */ | |
| 41 | + public function get_payment_method( string $id ): ?Payment_Method_Interface { | |
| 42 | + $payment_methods = $this->get_payment_methods(); | |
| 43 | + if ( ! isset( $payment_methods[ $id ] ) ) { | |
| 44 | + return null; | |
| 45 | + } | |
| 46 | + | |
| 47 | + return new $payment_methods[ $id ](); | |
| 48 | + } | |
| 49 | +} | |