Lines
100.00%
17 / 17
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RuntimeSnapshot | 100.00% | 17 / 17 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| withOnlyApps | 100.00% | 16 / 16 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Control\Protocol\Status; | |
| 6 | ||
| 7 | use Stewart\Contracts\Time\Instant; | |
| 8 | use Stewart\Contracts\Wire\ListOf; | |
| 9 | use Stewart\Store\StoreHealth; | |
| 10 | ||
| 11 | final readonly class RuntimeSnapshot | |
| 12 | { | |
| 13 | /** | |
| 14 | * @param list<WorkerStatus> $workers | |
| 15 | * @param list<AppStatus> $apps | |
| 16 | * @param list<RegistrationInfo> $subscriptions | |
| 17 | * @param list<ScheduleStatus> $schedules | |
| 18 | */ | |
| 19 | public function __construct( | |
| 20 | public Instant $takenAt, | |
| 21 | public DaemonInfo $daemon, | |
| 22 | public ConnectionState $connection, | |
| 23 | public BrokerStats $broker, | |
| 24 | #[ListOf(WorkerStatus::class)] | |
| 25 | public array $workers, | |
| 26 | #[ListOf(AppStatus::class)] | |
| 27 | public array $apps, | |
| 28 | #[ListOf(RegistrationInfo::class)] | |
| 29 | public array $subscriptions, | |
| 30 | public ?StoreHealth $store = null, | |
| 31 | public ?DeployStatus $deploy = null, | |
| 32 | public ?ComponentStatus $component = null, | |
| 33 | public ?ReloadStatus $reload = null, | |
| 34 | #[ListOf(ScheduleStatus::class)] | |
| 35 | public array $schedules = [], | |
| 36 | public ?MqttStatus $mqtt = null, | |
| 37 | public ?GeneratedCodeStatus $generated = null, | |
| 38 | ) {} | |
| 39 | ||
| 40 | /** @param list<string> $appIds */ | |
| 41 | public function withOnlyApps(array $appIds): self | |
| 42 | { | |
| 43 | return new self( | |
| 44 | takenAt: $this->takenAt, | |
| 45 | daemon: $this->daemon, | |
| 46 | connection: $this->connection, | |
| 47 | broker: $this->broker, | |
| 48 | workers: $this->workers, | |
| 49 | apps: array_values(array_filter($this->apps, static fn(AppStatus $app): bool => \in_array($app->id, $appIds, true))), | |
| 50 | subscriptions: array_values(array_filter($this->subscriptions, static fn(RegistrationInfo $subscription): bool => \in_array($subscription->appId, $appIds, true))), | |
| 51 | store: $this->store, | |
| 52 | deploy: $this->deploy, | |
| 53 | component: $this->component, | |
| 54 | reload: $this->reload, | |
| 55 | schedules: array_values(array_filter($this->schedules, static fn(ScheduleStatus $schedule): bool => \in_array($schedule->appId, $appIds, true))), | |
| 56 | mqtt: $this->mqtt, | |
| 57 | generated: $this->generated, | |
| 58 | ); | |
| 59 | } | |
| 60 | } |