MessageRole.php

Code Hygiene Score: 100

Keine Issues gefunden.

Klassen 1

Funktionen 4

Verwendet von 3

Code

<?php

declare(strict_types=1);

namespace Domain\ValueObject;

// @responsibility: Chat-Message-Rolle (user/assistant/system)

enum MessageRole: string
{
    case USER = 'user';
    case ASSISTANT = 'assistant';
    case SYSTEM = 'system';

    /**
     * Get human-readable label.
     */
    public function label(): string
    {
        return match ($this) {
            self::USER => 'Benutzer',
            self::ASSISTANT => 'Assistent',
            self::SYSTEM => 'System',
        };
    }

    /**
     * Check if this is a user message.
     */
    public function isUser(): bool
    {
        return $this === self::USER;
    }

    /**
     * Check if this is an assistant response.
     */
    public function isAssistant(): bool
    {
        return $this === self::ASSISTANT;
    }

    /**
     * Check if this is a system prompt.
     */
    public function isSystem(): bool
    {
        return $this === self::SYSTEM;
    }
}
← Übersicht Graph