Final Class Yiisoft\Html\IdGenerator
| Inheritance | Yiisoft\ |
|---|
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $counter | array |
Yiisoft\ |
|
| $useSeed | boolean | Yiisoft\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| generate() | Yiisoft\ |
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;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.