mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
37 lines
601 B
PHP
37 lines
601 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pest\Concerns;
|
|
|
|
use Closure;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
trait Extendable
|
|
{
|
|
/**
|
|
* The list of extends.
|
|
*
|
|
* @var array<string, Closure>
|
|
*/
|
|
private static array $extends = [];
|
|
|
|
/**
|
|
* Register a new 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);
|
|
}
|
|
}
|