Files
trafficpumper/app/Serp/Data/SerpResponse.php
T
2026-08-29 15:53:53 +03:00

25 lines
944 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Serp\Data;
use InvalidArgumentException;
final readonly class SerpResponse
{
public array $results;
public function __construct(public string $providerKey, array $results, public ?string $referenceId = null, int $limit = 100, public string|int|float|null $cost = null, public string $currency = 'USD', public ?int $statusCode = null)
{
if (count($results) > $limit) {
throw new InvalidArgumentException('Sonuç limiti aşıldı.');
}foreach ($results as $r) {
if (! $r instanceof SerpResultData) {
throw new InvalidArgumentException('Geçersiz sonuç verisi.');
}
}$positions = array_map(fn ($r) => $r->position, $results);
if (count($positions) !== count(array_unique($positions))) {
throw new InvalidArgumentException('Tekrarlanan sonuç pozisyonu.');
}$this->results = array_values($results);
}
}