mirror of
https://github.com/pestphp/pest.git
synced 2026-04-20 22:20:17 +02:00
41 lines
673 B
PHP
41 lines
673 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pest\Concerns;
|
|
|
|
use Closure;
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @template T of object
|
|
*/
|
|
trait Extendable
|
|
{
|
|
/**
|
|
* The list of extends.
|
|
*
|
|
* @var array<string, Closure>
|
|
*/
|
|
private static array $extends = [];
|
|
|
|
/**
|
|
* Register a new extend.
|
|
*
|
|
* @param-closure-this T $extend
|
|
*/
|
|
public function extend(string $name, Closure $extend): void
|
|
{
|
|
static::$extends[$name] = $extend;
|
|
}
|
|
|
|
/**
|
|
* Checks if given extend name is registered.
|
|
*/
|
|
public static function hasExtend(string $name): bool
|
|
{
|
|
return array_key_exists($name, static::$extends);
|
|
}
|
|
}
|