Spaces:
Sleeping
Sleeping
File size: 2,471 Bytes
097eaf0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <?php
declare(strict_types=1);
namespace Firecrawl\Models;
final class SearchOptions
{
/**
* @param list<mixed>|null $sources
* @param list<mixed>|null $categories
* @param list<string>|null $includeDomains
* @param list<string>|null $excludeDomains
*/
private function __construct(
private readonly ?array $sources = null,
private readonly ?array $categories = null,
private readonly ?int $limit = null,
private readonly ?string $tbs = null,
private readonly ?string $location = null,
private readonly ?bool $ignoreInvalidURLs = null,
private readonly ?int $timeout = null,
private readonly ?ScrapeOptions $scrapeOptions = null,
private readonly ?string $integration = null,
private readonly ?array $includeDomains = null,
private readonly ?array $excludeDomains = null,
) {}
/**
* @param list<mixed>|null $sources
* @param list<mixed>|null $categories
* @param list<string>|null $includeDomains
* @param list<string>|null $excludeDomains
*/
public static function with(
?array $sources = null,
?array $categories = null,
?int $limit = null,
?string $tbs = null,
?string $location = null,
?bool $ignoreInvalidURLs = null,
?int $timeout = null,
?ScrapeOptions $scrapeOptions = null,
?string $integration = null,
?array $includeDomains = null,
?array $excludeDomains = null,
): self {
return new self(
$sources, $categories, $limit, $tbs, $location, $ignoreInvalidURLs,
$timeout, $scrapeOptions, $integration, $includeDomains, $excludeDomains,
);
}
/** @return array<string, mixed> */
public function toArray(): array
{
$fields = [
'sources' => $this->sources,
'categories' => $this->categories,
'includeDomains' => $this->includeDomains,
'excludeDomains' => $this->excludeDomains,
'limit' => $this->limit,
'tbs' => $this->tbs,
'location' => $this->location,
'ignoreInvalidURLs' => $this->ignoreInvalidURLs,
'timeout' => $this->timeout,
'scrapeOptions' => $this->scrapeOptions?->toArray(),
'integration' => $this->integration,
];
return array_filter($fields, fn (mixed $v): bool => $v !== null);
}
}
|