This repository has been archived on 2021-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-09-20 12:55:34 +02:00
|
|
|
<?php declare(strict_types=1);
|
2021-09-20 12:53:56 +02:00
|
|
|
|
|
|
|
namespace MMK2410\MyTodoList;
|
|
|
|
|
|
|
|
class IdManager
|
|
|
|
{
|
2021-09-20 12:54:57 +02:00
|
|
|
private static array $ids = array();
|
2021-09-20 12:53:56 +02:00
|
|
|
|
2021-09-20 12:54:57 +02:00
|
|
|
public static function generateID(string $classname): int
|
|
|
|
{
|
|
|
|
if (!array_key_exists($classname, self::$ids)) {
|
|
|
|
self::$ids[$classname] = 0;
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return ++self::$ids[$classname];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getCurrentId(string $classname)
|
|
|
|
{
|
|
|
|
if (!array_key_exists($classname, self::$ids)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return self::$ids[$classname];
|
|
|
|
}
|
|
|
|
}
|
2021-09-20 12:53:56 +02:00
|
|
|
}
|