Lines 40.00% 2 / 5
Functions and Methods 66.66% 2 / 3
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
WorkerSlot 40.00% 2 / 5 66.66% 2 / 3 4.94 0.00% 0 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 listAppIds 100.00% 1 / 1 100.00% 1 / 1 1
 listWorkerApps 0.00% 0 / 3 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Broker;
6
7use Stewart\Contracts\App\Collection\AppIdCollection;
8use Stewart\Runtime\App\AppDefinition;
9use Stewart\Runtime\App\Collection\AppDefinitionCollection;
10use Stewart\Runtime\Ipc\Collection\WorkerAppCollection;
11use Stewart\Runtime\Ipc\WorkerApp;
12use Stewart\Runtime\Model\WorkerId;
13
14final readonly class WorkerSlot
15{
16    public function __construct(
17        public WorkerId $workerId,
18        public AppDefinitionCollection $apps,
19    ) {}
20
21    public function listAppIds(): AppIdCollection
22    {
23        return AppIdCollection::fromList($this->apps->mapToList(static fn(AppDefinition $app) => $app->id));
24    }
25
26    public function listWorkerApps(): WorkerAppCollection
27    {
28        return WorkerAppCollection::fromList($this->apps->mapToList(
29            static fn(AppDefinition $app): WorkerApp => new WorkerApp($app->id, $app->class, $app->options),
30        ));
31    }
32}