|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/pelasgus.al/wp-content/plugins/code-snippets/php/Flat_Files/ | |
|
Path: //home2/gazetufm/pelasgus.al/wp-content/plugins/code-snippets/php/Flat_Files/Handler_Registry.php
Size: 1.18 KB
Permissions: 0644
<?php
namespace Code_Snippets\Flat_Files;
use Code_Snippets\Flat_Files\Interfaces\Snippet_Type_Handler;
/**
* Class for storing registered handlers for converting the different snippet types into flat files.
*
* @package Code_Snippets
*/
class Handler_Registry {
/**
* List of type handlers.
*
* @var Snippet_Type_Handler[]
*/
private array $handlers = [];
/**
* Constructor.
*
* @param Snippet_Type_Handler[] $handlers Snippet type handlers to register.
*/
public function __construct( array $handlers ) {
foreach ( $handlers as $type => $handler ) {
$this->register_handler( $type, $handler );
}
}
/**
* Registers a handler for a snippet type.
*
* @param string $type Handler key.
* @param Snippet_Type_Handler $handler Handler class.
*
* @return void
*/
public function register_handler( string $type, Snippet_Type_Handler $handler ): void {
$this->handlers[ $type ] = $handler;
}
/**
* Gets the handler for a snippet type.
*
* @param string $type Handler key.
*
* @return Snippet_Type_Handler|null
*/
public function get_handler( string $type ): ?Snippet_Type_Handler {
return $this->handlers[ $type ] ?? null;
}
}