trove/app/Services/PolitenessService.php

20 lines
473 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace App\Services;
class PolitenessService
{
public function minDelayFor(string $domain): int
{
/** @var RobotsService $robotsService */
$robotsService = resolve(RobotsService::class);
$crawlDelay = $robotsService->crawlDelayFor($domain, config('crawler.user_agent'));
$configValue = config('crawler.min_domain_delay_seconds', 10);
return max($crawlDelay ?? 0, $configValue);
}
}