EntityType.php

Code Hygiene Score: 100

Keine Issues gefunden.

Klassen 1

Funktionen 4

Code

<?php

declare(strict_types=1);

namespace Domain\ValueObject;

// @responsibility: Entity-Typ-Enum für Wissensgraph-Entitäten

enum EntityType: string
{
    case PERSON = 'PERSON';
    case ORGANIZATION = 'ORGANIZATION';
    case LOCATION = 'LOCATION';
    case CONCEPT = 'CONCEPT';
    case METHOD = 'METHOD';
    case TOOL = 'TOOL';
    case EVENT = 'EVENT';
    case OTHER = 'OTHER';

    /**
     * Get human-readable label.
     */
    public function label(): string
    {
        return match ($this) {
            self::PERSON => 'Person',
            self::ORGANIZATION => 'Organisation',
            self::LOCATION => 'Ort',
            self::CONCEPT => 'Konzept',
            self::METHOD => 'Methode',
            self::TOOL => 'Werkzeug',
            self::EVENT => 'Ereignis',
            self::OTHER => 'Sonstiges',
        };
    }

    /**
     * Get icon for display.
     */
    public function icon(): string
    {
        return match ($this) {
            self::PERSON => 'user',
            self::ORGANIZATION => 'building',
            self::LOCATION => 'map-pin',
            self::CONCEPT => 'lightbulb',
            self::METHOD => 'clipboard-list',
            self::TOOL => 'wrench',
            self::EVENT => 'calendar',
            self::OTHER => 'box',
        };
    }

    /**
     * Get CSS color class.
     */
    public function colorClass(): string
    {
        return match ($this) {
            self::PERSON => 'blue',
            self::ORGANIZATION => 'purple',
            self::LOCATION => 'green',
            self::CONCEPT => 'yellow',
            self::METHOD => 'orange',
            self::TOOL => 'gray',
            self::EVENT => 'red',
            self::OTHER => 'slate',
        };
    }

    /**
     * Check if this is a primary entity type (commonly extracted).
     */
    public function isPrimary(): bool
    {
        return in_array($this, [self::PERSON, self::ORGANIZATION, self::CONCEPT], true);
    }
}
← Übersicht Graph