Files
033f0c84da v4.7 (#12478)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Co-authored-by: Aditya Tripathi <aditya@climactic.co>
2026-11-06 14:25:02 +01:00

41 lines
1.1 KiB
PHP

<?php
namespace App\Services\ImageScan;
use App\Models\ImageScanIgnore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
/**
* What decides relevance for one resource (spec 15.2): its active ignores and the "Count medium problems" rule.
*/
final readonly class RelevanceRules
{
public function __construct(
public IgnoreMatcher $ignores,
public bool $countMedium = false,
) {}
public static function forResource(Model $resource): self
{
return new self(IgnoreMatcher::forResource($resource), ImageScanPolicyResolver::countMediumFor($resource));
}
/**
* @param Collection<int, ImageScanIgnore> $ignores
*/
public static function fromIgnores(Collection $ignores, bool $countMedium = false): self
{
return new self(IgnoreMatcher::fromIgnores($ignores), $countMedium);
}
/**
* The same ignores with every medium counted. Version and base checks store the IDs they fix with these, so a
* change of the rule needs no new check.
*/
public function withAllMediums(): self
{
return new self($this->ignores, true);
}
}