identifier = $identifier; $this->normalizedIdentifier = $normalizedIdentifier; $this->domain = $domain; $this->source = $source; $this->retrievedAt = $retrievedAt; $this->expiresAt = $expiresAt; $this->metadata = $metadata; $this->images = array_values($images); $this->quality = $quality; $this->fingerprint = $fingerprint; $this->hash = $hash; $this->language = strtolower(trim($language)); $this->country = strtoupper(trim($country)); $this->version = $version; $this->valid = $valid; $this->merged = $merged; } public function getIdentifier(): string { return $this->identifier; } public function getNormalizedIdentifier(): string { return $this->normalizedIdentifier; } public function getDomain(): string { return $this->domain; } public function getProvider(): string { return $this->source->getProvider(); } public function getSource(): KnowledgeSource { return $this->source; } public function getRetrievedAt(): \DateTimeImmutable { return $this->retrievedAt; } public function getExpiresAt(): \DateTimeImmutable { return $this->expiresAt; } public function getMetadata(): array { return $this->metadata; } public function getImages(): array { return $this->images; } public function getQuality(): KnowledgeQuality { return $this->quality; } public function getQualityScore(): float { return $this->quality->getQualityScore(); } public function getProviderScore(): float { return $this->quality->getProviderScore(); } public function getFingerprint(): string { return $this->fingerprint; } public function getHash(): string { return $this->hash; } public function getLanguage(): string { return $this->language; } public function getCountry(): string { return $this->country; } public function getVersion(): KnowledgeVersion { return $this->version; } public function isValid(): bool { return $this->valid; } public function isMerged(): bool { return $this->merged; } public function getStatus(KnowledgePolicy $policy, \DateTimeImmutable $at): string { return $policy->getStatus($this, $at); } public function withVersion(KnowledgeVersion $version): self { return new self( $this->identifier, $this->normalizedIdentifier, $this->domain, $this->source, $this->retrievedAt, $this->expiresAt, $this->metadata, $this->images, $this->quality, $this->fingerprint, $this->hash, $this->language, $this->country, $version, $this->valid, $this->merged ); } public function toArray(): array { return [ 'identifier' => $this->identifier, 'normalized_identifier' => $this->normalizedIdentifier, 'domain' => $this->domain, 'provider' => $this->getProvider(), 'retrieved_at' => $this->retrievedAt->format(DATE_ATOM), 'expires_at' => $this->expiresAt->format(DATE_ATOM), 'metadata' => $this->metadata, 'images' => $this->images, 'quality_score' => $this->getQualityScore(), 'provider_score' => $this->getProviderScore(), 'fingerprint' => $this->fingerprint, 'hash' => $this->hash, 'language' => $this->language, 'country' => $this->country, 'version' => $this->version->getNumber(), ]; } }