SessionMetadata.php
- Pfad:
src/Domain/ValueObject/SessionMetadata.php - Namespace: Domain\ValueObject
- Zeilen: 160 | Größe: 4,526 Bytes
- Geändert: 2025-12-26 20:57:45 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 84
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 20 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 1
- use InvalidArgumentException
Klassen 1
-
SessionMetadataclass Zeile 11
Funktionen 18
-
__construct()private Zeile 16 -
create()public Zeile 28 -
getModel()public Zeile 44 -
getCollections()public Zeile 52 -
getContextLimit()public Zeile 57 -
getTemperature()public Zeile 62 -
getMaxTokens()public Zeile 67 -
withModel()public Zeile 72 -
withCollections()public Zeile 82 -
withContextLimit()public Zeile 89 -
withTemperature()public Zeile 96 -
withMaxTokens()public Zeile 103 -
validateModel()private Zeile 110 -
validateCollections()private Zeile 120 -
validateContextLimit()private Zeile 130 -
validateTemperature()private Zeile 137 -
validateMaxTokens()private Zeile 144 -
equals()public Zeile 151
Verwendet von 3
- ChatSession.php use
- ChatSession.php constructor
- ChatSessionFactory.php use
Versionen 3
-
v3
2025-12-26 20:57 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v2
2025-12-25 17:26 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-25 17:21 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation
Code
<?php
declare(strict_types=1);
namespace Domain\ValueObject;
// @responsibility: Immutable Value Object für Chat-Session-Metadaten (Model, Collections, Context, etc.)
use InvalidArgumentException;
final class SessionMetadata
{
/**
* @param array<string> $collections
*/
private function __construct(
private string $model,
private array $collections,
private int $contextLimit,
private float $temperature,
private int $maxTokens
) {
}
/**
* @param array<string> $collections
*/
public static function create(
string $model = 'claude-opus-4-5-20251101',
array $collections = ['documents'],
int $contextLimit = 5,
float $temperature = 0.7,
int $maxTokens = 4096
): self {
self::validateModel($model);
self::validateCollections($collections);
self::validateContextLimit($contextLimit);
self::validateTemperature($temperature);
self::validateMaxTokens($maxTokens);
return new self($model, $collections, $contextLimit, $temperature, $maxTokens);
}
public function getModel(): string
{
return $this->model;
}
/**
* @return array<string>
*/
public function getCollections(): array
{
return $this->collections;
}
public function getContextLimit(): int
{
return $this->contextLimit;
}
public function getTemperature(): float
{
return $this->temperature;
}
public function getMaxTokens(): int
{
return $this->maxTokens;
}
public function withModel(string $model): self
{
self::validateModel($model);
return new self($model, $this->collections, $this->contextLimit, $this->temperature, $this->maxTokens);
}
/**
* @param array<string> $collections
*/
public function withCollections(array $collections): self
{
self::validateCollections($collections);
return new self($this->model, $collections, $this->contextLimit, $this->temperature, $this->maxTokens);
}
public function withContextLimit(int $contextLimit): self
{
self::validateContextLimit($contextLimit);
return new self($this->model, $this->collections, $contextLimit, $this->temperature, $this->maxTokens);
}
public function withTemperature(float $temperature): self
{
self::validateTemperature($temperature);
return new self($this->model, $this->collections, $this->contextLimit, $temperature, $this->maxTokens);
}
public function withMaxTokens(int $maxTokens): self
{
self::validateMaxTokens($maxTokens);
return new self($this->model, $this->collections, $this->contextLimit, $this->temperature, $maxTokens);
}
private static function validateModel(string $model): void
{
if (trim($model) === '') {
throw new InvalidArgumentException('Model cannot be empty');
}
}
/**
* @param array<string> $collections
*/
private static function validateCollections(array $collections): void
{
// Empty collections allowed - user can chat without RAG context
foreach ($collections as $collection) {
if (trim($collection) === '') {
throw new InvalidArgumentException('Each collection must be a non-empty string');
}
}
}
private static function validateContextLimit(int $contextLimit): void
{
if ($contextLimit < 1 || $contextLimit > 20) {
throw new InvalidArgumentException('Context limit must be between 1 and 20');
}
}
private static function validateTemperature(float $temperature): void
{
if ($temperature < 0.0 || $temperature > 1.0) {
throw new InvalidArgumentException('Temperature must be between 0.0 and 1.0');
}
}
private static function validateMaxTokens(int $maxTokens): void
{
if ($maxTokens < 1 || $maxTokens > 100000) {
throw new InvalidArgumentException('Max tokens must be between 1 and 100000');
}
}
public function equals(self $other): bool
{
return $this->model === $other->model
&& $this->collections === $other->collections
&& $this->contextLimit === $other->contextLimit
&& abs($this->temperature - $other->temperature) < 0.0001
&& $this->maxTokens === $other->maxTokens;
}
}