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 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Broker; | |
| 6 | ||
| 7 | use Stewart\Contracts\App\Collection\AppIdCollection; | |
| 8 | use Stewart\Runtime\App\AppDefinition; | |
| 9 | use Stewart\Runtime\App\Collection\AppDefinitionCollection; | |
| 10 | use Stewart\Runtime\Ipc\Collection\WorkerAppCollection; | |
| 11 | use Stewart\Runtime\Ipc\WorkerApp; | |
| 12 | use Stewart\Runtime\Model\WorkerId; | |
| 13 | ||
| 14 | final 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 | } |