0 follower

Final Class Yiisoft\Html\IdGenerator

InheritanceYiisoft\Html\IdGenerator

Public Properties

Hide inherited properties

Property Type Description Defined By
$counter array Yiisoft\Html\IdGenerator
$useSeed boolean Yiisoft\Html\IdGenerator

Public Methods

Hide inherited methods

Method Description Defined By
generate() Yiisoft\Html\IdGenerator

Property Details

Hide inherited properties

$counter public static property
public static array $counter = []
$useSeed public static property
public static boolean $useSeed true

Method Details

Hide inherited methods

generate() public static method

public static string generate ( string $prefix )
$prefix string

                public static function generate(string $prefix): string
{
    if (self::$useSeed) {
        $prefix .= hrtime(true);
    }
    if (isset(self::$counter[$prefix])) {
        $count = ++self::$counter[$prefix];
    } else {
        $count = 1;
        if (self::$useSeed) {
            self::$counter = [$prefix => $count];
        } else {
            self::$counter[$prefix] = $count;
        }
    }
    return $prefix . $count;
}