| Server IP : 46.105.57.169 / Your IP : 216.73.216.144 Web Server : Apache System : Linux webd003.cluster120.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : maitricfuz ( 93378) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/maitricfuz/www/maitric/libraries/vendor/jfcherng/php-diff/src/Factory/ |
Upload File : |
<?php
declare(strict_types=1);
namespace Jfcherng\Diff\Factory;
use Jfcherng\Diff\Renderer\Html\LineRenderer\AbstractLineRenderer;
use Jfcherng\Diff\Renderer\RendererConstant;
final class LineRendererFactory
{
/**
* Instances of line renderers.
*
* @var AbstractLineRenderer[]
*/
private static array $singletons = [];
/**
* The constructor.
*/
private function __construct()
{
}
/**
* Get the singleton of a line renderer.
*
* @param string $type the type
* @param mixed ...$ctorArgs the constructor arguments
*/
public static function getInstance(string $type, ...$ctorArgs): AbstractLineRenderer
{
return self::$singletons[$type] ??= self::make($type, ...$ctorArgs);
}
/**
* Make a new instance of a line renderer.
*
* @param string $type the type
* @param mixed ...$ctorArgs the constructor arguments
*
* @throws \InvalidArgumentException
*/
public static function make(string $type, ...$ctorArgs): AbstractLineRenderer
{
$className = RendererConstant::RENDERER_NAMESPACE . '\\Html\\LineRenderer\\' . ucfirst($type);
if (!class_exists($className)) {
throw new \InvalidArgumentException("LineRenderer not found: {$type}");
}
return new $className(...$ctorArgs);
}
}