Lines 0.00% 0 / 5
Functions and Methods 0.00% 0 / 4
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ProjectCheckResult 0.00% 0 / 5 0.00% 0 / 4 20 0.00% 0 / 1
 __construct 0.00% 0 / 1 0.00% 0 / 1 2
 passed 0.00% 0 / 1 0.00% 0 / 1 2
 failed 0.00% 0 / 2 0.00% 0 / 1 2
 hasPassed 0.00% 0 / 1 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Console\Check;
6
7use Stewart\Contracts\App\Collection\AppIdCollection;
8use Stewart\Runtime\App\AppCatalog;
9use Stewart\Runtime\App\Collection\AppDefinitionCollection;
10use Stewart\Runtime\App\DiscoveryResult;
11use Stewart\Runtime\Broker\Collection\WorkerSlotCollection;
12use Stewart\Runtime\Config\CodegenConfig;
13
14final readonly class ProjectCheckResult
15{
16    /** @param list<string> $errors */
17    private function __construct(
18        public array $errors,
19        public DiscoveryResult $discovered,
20        public AppCatalog $catalog,
21        public WorkerSlotCollection $workerSlots,
22        public ?CodegenConfig $codegen = null,
23        public ?string $httpListenerError = null,
24    ) {}
25
26    public static function passed(DiscoveryResult $discovered, AppCatalog $catalog, WorkerSlotCollection $workerSlots, CodegenConfig $codegen, ?string $httpListenerError): self
27    {
28        return new self([], $discovered, $catalog, $workerSlots, $codegen, $httpListenerError);
29    }
30
31    /** @param list<string> $errors */
32    public static function failed(array $errors): self
33    {
34        $none = AppIdCollection::empty();
35
36        return new self($errors, DiscoveryResult::createEmpty(), new AppCatalog(AppDefinitionCollection::keyedByAppId([]), $none, $none), WorkerSlotCollection::empty());
37    }
38
39    public function hasPassed(): bool
40    {
41        return $this->errors === [];
42    }
43}