35 lines
910 B
PHP
35 lines
910 B
PHP
<?php
|
|
|
|
namespace KupShop\SystemInspectionBundle\Util;
|
|
|
|
use KupShop\SystemInspectionBundle\Inspections\Inspection;
|
|
use KupShop\SystemInspectionBundle\InspectionWriters\InspectionWriterVisitor;
|
|
|
|
class InspectionRunner
|
|
{
|
|
protected $inspectionLocator;
|
|
|
|
public function __construct(InspectionLocator $inspectionLocator)
|
|
{
|
|
$this->inspectionLocator = $inspectionLocator;
|
|
}
|
|
|
|
public function runInspection(string $type, InspectionWriterVisitor $visitor)
|
|
{
|
|
/***
|
|
* @var Inspection[] $inspections
|
|
*/
|
|
$inspections = $this->inspectionLocator->getInspections($type);
|
|
|
|
foreach ($inspections as $inspection) {
|
|
if ($inspection->isEnabled()) {
|
|
foreach ($inspection->runInspection() ?? [] as $message) {
|
|
$message->accept($visitor);
|
|
}
|
|
}
|
|
}
|
|
|
|
$visitor->end();
|
|
}
|
|
}
|