mmk2410
/
my-todo-list
Archived
1
0
Fork 0
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.
my-todo-list/src/IdManager.php

27 lines
636 B
PHP
Raw Permalink Normal View History

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
}