<?php

namespace App\Helpers\FirstParty\SitemapCrawler;

use Spatie\Crawler\CrawlProfiles\CrawlProfile;
use Psr\Http\Message\UriInterface;

class CustomCrawlProfile extends CrawlProfile
{
    /** @var callable */
    protected $callback;

    public function shouldCrawlCallback(callable $callback): void
    {
        $this->callback = $callback;
    }

    public function shouldCrawl(UriInterface $url): bool
    {
        if ($url->getQuery() !== '') {
            return false;
        }
        

        return ($this->callback)($url);
    }

}
