$catalog Short-form problems against Divi's live catalog. * @param Closure(): string $version Installed Divi version ('' = unknown). * @param Closure(string): string $stateKey ReleaseResolver::stateKey(). */ public function __construct( private ManifestCheck $manifests, private Closure $catalog, private FormatCheck $format, private WriteProbe $probe, private Closure $version, private Closure $stateKey ) { } public static function create(ContentComposer $composer): self { return new self( new ManifestCheck(), static fn (): array => DiviModules::isAvailable() ? ShortformCheck::problems((new DiviModules())->catalog()) : ['Divi 5 ist in dieser Anfrage nicht geladen.'], new FormatCheck(), new WriteProbe($composer), static fn (): string => DiviEnvironment::version() ?? '', static fn (string $version): string => ReleaseResolver::stateKey($version) ); } public function run(int $userId): CheckReport { $manifest = self::guarded(fn (): array => ManifestCheck::failed( array_merge($this->manifests->codeChecks(), $this->manifests->registrationChecks()) )); $steps = [ new CheckStep(CheckStep::MANIFEST, $manifest), new CheckStep(CheckStep::MIRRORS, self::guarded( fn (): array => ManifestCheck::failed($this->manifests->mirrorChecks()) )), new CheckStep(CheckStep::CATALOG, self::guarded($this->catalog)), new CheckStep(CheckStep::FORMAT, self::guarded(fn (): array => $this->format->problems())), $manifest === [] ? new CheckStep(CheckStep::WRITE, self::guarded(fn (): array => $this->probe->run())) : new CheckStep(CheckStep::WRITE, [], true), ]; $version = ($this->version)(); return new CheckReport( wp_generate_uuid4(), gmdate('c'), $userId, $version, Plugin::VERSION, ($this->stateKey)($version), $steps ); } /** @return list */ private static function guarded(Closure $step): array { try { return array_values(array_filter((array) $step(), 'is_string')); } catch (Throwable $e) { return ['Prüfschritt abgebrochen: ' . $e->getMessage()]; } } }