MessageMetadata.php
- Pfad:
src/Domain/ValueObject/MessageMetadata.php - Namespace: Domain\ValueObject
- Zeilen: 133 | Größe: 3,373 Bytes
- Geändert: 2025-12-25 16:56:27 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 92
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 60 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Klassen 1
-
MessageMetadataclass Zeile 9
Funktionen 14
-
__construct()private Zeile 27 -
create()public Zeile 44 -
sources()public Zeile 59 -
collections()public Zeile 65 -
chunksUsed()public Zeile 71 -
contextLimit()public Zeile 76 -
hasSources()public Zeile 81 -
hasCollections()public Zeile 86 -
hasChunks()public Zeile 91 -
withSources()public Zeile 99 -
withCollections()public Zeile 107 -
withChunksUsed()public Zeile 115 -
withContextLimit()public Zeile 120 -
equals()public Zeile 125
Verwendet von 3
- ChatMessage.php constructor
- ChatMessage.php use
- ChatMessageFactory.php use
Code
<?php
declare(strict_types=1);
namespace Domain\ValueObject;
// @responsibility: Immutable Value Object for message metadata (sources, chunks, collections)
final class MessageMetadata
{
/** @var array<mixed>|null */
private ?array $sources;
/** @var array<string>|null */
private ?array $collections;
/** @var array<mixed>|null */
private ?array $chunksUsed;
private ?int $contextLimit;
/**
* @param array<mixed>|null $sources
* @param array<string>|null $collections
* @param array<mixed>|null $chunksUsed
*/
private function __construct(
?array $sources,
?array $collections,
?array $chunksUsed,
?int $contextLimit
) {
$this->sources = $sources;
$this->collections = $collections;
$this->chunksUsed = $chunksUsed;
$this->contextLimit = $contextLimit;
}
/**
* @param array<mixed>|null $sources
* @param array<string>|null $collections
* @param array<mixed>|null $chunksUsed
*/
public static function create(
?array $sources = null,
?array $collections = null,
?array $chunksUsed = null,
?int $contextLimit = null
): self {
return new self($sources, $collections, $chunksUsed, $contextLimit);
}
public static function empty(): self
{
return new self(null, null, null, null);
}
/** @return array<mixed>|null */
public function sources(): ?array
{
return $this->sources;
}
/** @return array<string>|null */
public function collections(): ?array
{
return $this->collections;
}
/** @return array<mixed>|null */
public function chunksUsed(): ?array
{
return $this->chunksUsed;
}
public function contextLimit(): ?int
{
return $this->contextLimit;
}
public function hasSources(): bool
{
return $this->sources !== null && count($this->sources) > 0;
}
public function hasCollections(): bool
{
return $this->collections !== null && count($this->collections) > 0;
}
public function hasChunks(): bool
{
return $this->chunksUsed !== null && count($this->chunksUsed) > 0;
}
/**
* @param array<mixed> $sources
*/
public function withSources(array $sources): self
{
return new self($sources, $this->collections, $this->chunksUsed, $this->contextLimit);
}
/**
* @param array<string> $collections
*/
public function withCollections(array $collections): self
{
return new self($this->sources, $collections, $this->chunksUsed, $this->contextLimit);
}
/**
* @param array<mixed> $chunksUsed
*/
public function withChunksUsed(array $chunksUsed): self
{
return new self($this->sources, $this->collections, $chunksUsed, $this->contextLimit);
}
public function withContextLimit(int $contextLimit): self
{
return new self($this->sources, $this->collections, $this->chunksUsed, $contextLimit);
}
public function equals(self $other): bool
{
return $this->sources === $other->sources
&& $this->collections === $other->collections
&& $this->chunksUsed === $other->chunksUsed
&& $this->contextLimit === $other->contextLimit;
}
}