<?php
/**
 * ID Generator
 *
 * PHP version 8.2+
 *
 * Generates unique identifiers for tasks and related files.
 *
 * @category Support
 * @package  IronKanban\Support
 * @author   Keith Solomon <keith@keithsolomon.net>
 * @license  Unlicense https://unlicense.org
 * @link     https://git.keithsolomon.net/keith/IronKanban
 */

declare(strict_types=1);

namespace IronKanban\Support;

/**
 * IdGenerator generates unique identifiers
 *
 * @category Support
 * @package  IronKanban\Support
 * @author   Keith Solomon <keith@keithsolomon.net>
 * @license  Unlicense https://unlicense.org
 * @link     https://git.keithsolomon.net/keith/IronKanban
 */
class IdGenerator {
    /**
     * Generate a unique task ID
     *
     * @return string The generated task ID
     */
    public function generateTaskId(): string {
        return 'task-' . gmdate('Ymd-His') . '-' .
            substr(bin2hex(random_bytes(3)), 0, 6);
    }

    /**
     * Generate a task file name
     *
     * @param string $taskId The task identifier
     *
     * @return string The generated file name
     */
    public function generateTaskFileName(string $taskId): string {
        return $taskId . '.md';
    }
}
