<?php

namespace App\Libraries;

use App\Libraries\CommonLibrary;
use Symfony\Component\DomCrawler\Crawler;

abstract class MyCrawlerLibrary extends CommonLibrary
{
    protected function __construct()
    {
        parent::__construct();
    }
    abstract public function getMySocket();
    abstract public function getMyStorage();
    abstract public function execute(): void;
    final protected function getSelector(string $content, string $tag): Crawler
    {
        $crawler = new Crawler($content);
        if ($this->getDebug()) {
            log_message("debug", sprintf(
                "\n---------%s----------\ntag:%s\n%s\n-------------------\n",
                __FUNCTION__,
                $tag,
                $content
            ));
            exit;
        }
        return $crawler->filter($tag);
    }
}
