Files
Mangarr/tests/Domain/Scraping/Adapter/InMemoryScraperAdapter.php
ext.jeremy.guillot@maxicoffee.domains 073439163b feat: finalizing Scraping endpoint
2025-02-10 17:28:49 +01:00

34 lines
786 B
PHP

<?php
namespace App\Tests\Domain\Scraping\Adapter;
use App\Domain\Scraping\Domain\Contract\Service\ScraperInterface;
use App\Domain\Scraping\Domain\Model\ScrapingJob;
use Ramsey\Uuid\Uuid;
class InMemoryScraperAdapter implements ScraperInterface
{
private ?\Exception $shouldThrowException = null;
public function scrape(ScrapingJob $job): ScrapingJob
{
if ($this->shouldThrowException) {
$job->fail($this->shouldThrowException->getMessage());
return $job;
}
$job->complete();
return $job;
}
public function simulateError(\Exception $exception): void
{
$this->shouldThrowException = $exception;
}
public function supports(string $sourceType): bool
{
return true;
}
}