Files
Mangarr/tests/Domain/Scraping/Adapter/InMemoryScraperAdapter.php
ext.jeremy.guillot@maxicoffee.domains 55945adc53 feat: Reader beginning
2025-02-16 16:15:42 +01:00

36 lines
902 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 App\Domain\Scraping\Domain\Model\ValueObject\CbzPath;
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();
$job->cbzPath = new CbzPath('/path/to/test.cbz');
return $job;
}
public function simulateError(\Exception $exception): void
{
$this->shouldThrowException = $exception;
}
public function supports(string $sourceType): bool
{
return true;
}
}