*/ private array $verdicts = []; public int $scans = 0; /** @var list the sizes it was asked to read, in order */ public array $sizes = []; private ScannerStatus $status; public function __construct(?ScanVerdict $verdict = null) { if ($verdict !== null) { $this->verdicts[] = $verdict; } $this->status = new ScannerStatus(true, 'FakeAV 1.0', 1, now()); } /** Answer this next. Queued, so a test can say "down, then up". */ public function willAnswer(ScanVerdict ...$verdicts): self { foreach ($verdicts as $verdict) { $this->verdicts[] = $verdict; } return $this; } public function reports(ScannerStatus $status): self { $this->status = $status; return $this; } public function scan(mixed $stream, int $size): ScanVerdict { $this->scans++; $this->sizes[] = $size; // The last answer stands once the queue runs dry: a test that // says "infected" once means it, however many times the job is // retried. return count($this->verdicts) > 1 ? array_shift($this->verdicts) : ($this->verdicts[0] ?? ScanVerdict::clean('FakeAV 1.0')); } public function status(): ScannerStatus { return $this->status; } }