validate($value); } public static function fromString(string $value): self { return new self($value); } public function toString(): string { return $this->value; } public function __toString(): string { return $this->toString(); } public function equals(SessionId $other): bool { return $this->value === $other->value; } private function validate(string $value): void { if (empty($value)) { throw new InvalidArgumentException('SessionId darf nicht leer sein'); } // Weitere Validierungen je nach Anforderungen // z.B. Mindestlänge, erlaubte Zeichen, Format if (strlen($value) < 32) { throw new InvalidArgumentException('SessionId muss mindestens 32 Zeichen lang sein'); } if (!ctype_alnum($value)) { throw new InvalidArgumentException('SessionId darf nur alphanumerische Zeichen enthalten'); } } }