HEX
Server: LiteSpeed
System: Linux ragasnapis.serveriai.lt 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User: odxqitalt (1170)
PHP: 8.3.19
Disabled: link, symlink, exec, passthru, proc_close, proc_get_status, proc_open, shell_exec, system, popen, pclose, dl, show_source, highlight_file, pcntl_exec, ini_restore, ini_alter, chgrp
Upload Files
File: /home/odxqitalt/public_html/wp-content/plugins/code-snippets/php/flat-files/registry.php
<?php

namespace Code_Snippets;

class Snippet_Handler_Registry {
	/**
	 * @var Snippet_Type_Handler_Interface[]
	 */
	private array $handlers = [];

	/**
	 * Constructor
	 *
	 * @param Snippet_Type_Handler_Interface[] $handlers
	 */
	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
	 * @param Snippet_Type_Handler_Interface $handler
	 * @return void
	 */
	public function register_handler( string $type, Snippet_Type_Handler_Interface $handler ): void {
		$this->handlers[ $type ] = $handler;
	}

	/**
	 * Gets the handler for a snippet type.
	 *
	 * @param string $type
	 *
	 * @return Snippet_Type_Handler_Interface|null
	 */
	public function get_handler( string $type ): ?Snippet_Type_Handler_Interface {
		if ( ! isset( $this->handlers[ $type ] ) ) {
			return null;
		}

		return $this->handlers[ $type ];
	}
}