Lines 0.00% 0 / 23
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
CatalogWarnings 0.00% 0 / 23 0.00% 0 / 1 42 0.00% 0 / 1
 logCatalogWarnings 0.00% 0 / 23 0.00% 0 / 1 42
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\App;
6
7use Psr\Log\LoggerInterface;
8
9final readonly class CatalogWarnings
10{
11    public function logCatalogWarnings(DiscoveryResult $discovered, AppCatalog $apps, string $configPath, LoggerInterface $logger): void
12    {
13        foreach ($discovered->unmarked as $unmarked) {
14            $logger->warning('A class in apps/ implements App but is not marked #[Automation] or #[AppTemplate], so it will not run.', [
15                'class' => $unmarked->class,
16            ]);
17        }
18
19        foreach ($discovered->listUnusedTemplateClasses() as $template) {
20            $logger->notice('An #[AppTemplate] class runs only through apps.<id>.class, and no entry names it.', [
21                'class' => $template,
22            ]);
23        }
24
25        foreach ($discovered->unloadable as $file) {
26            $logger->error('A file in apps/ failed to load, so the automation it declares will not run.', [
27                'file' => $file->path,
28                'exception' => $file->cause,
29            ]);
30        }
31
32        if (!$apps->unmatchedOverrideIds->isEmpty()) {
33            $logger->warning('stewart.yaml or the environment configures automations that were not found, so their settings are ignored.', [
34                'apps' => $apps->unmatchedOverrideIds->toStrings(),
35                'known' => $apps->knownIds->toStrings(),
36            ]);
37        }
38
39        if ($apps->enabled->isEmpty()) {
40            $logger->warning('No automations to run; Stewart will connect and do nothing.', [
41                'config' => $configPath,
42                'found' => $discovered->apps->count(),
43            ]);
44        }
45    }
46}