Final Class Yiisoft\Html\IdGenerator
| Inheritance | Yiisoft\Html\IdGenerator |
|---|
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $counter | array |
Yiisoft\Html\IdGenerator | |
| $useSeed | boolean | Yiisoft\Html\IdGenerator |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| generate() | Yiisoft\Html\IdGenerator |
Property Details
Method Details
| 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;
}
Signup or Login in order to comment.