Lines
90.90%
10 / 11
Functions and Methods
75.00%
3 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ReconcileExposedEntities | 90.90% | 10 / 11 | 75.00% | 3 / 4 | 4.01 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| type | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| describe | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| toMessage | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Client\Connection\Command\Component; | |
| 6 | ||
| 7 | use Stewart\Client\Component\ExposedEntityAddress; | |
| 8 | use Stewart\Client\Component\ExposedEntityReconcile; | |
| 9 | use Stewart\Client\Connection\Command\HaCommand; | |
| 10 | ||
| 11 | final readonly class ReconcileExposedEntities implements HaCommand | |
| 12 | { | |
| 13 | public function __construct(public ExposedEntityReconcile $reconcile) {} | |
| 14 | ||
| 15 | public function type(): string | |
| 16 | { | |
| 17 | return 'stewart/entity/reconcile'; | |
| 18 | } | |
| 19 | ||
| 20 | public function describe(): string | |
| 21 | { | |
| 22 | return \sprintf('%s %s keeping %d entities', $this->type(), $this->reconcile->instance, $this->reconcile->keptAddresses->count()); | |
| 23 | } | |
| 24 | ||
| 25 | public function toMessage(): array | |
| 26 | { | |
| 27 | return [ | |
| 28 | 'type' => $this->type(), | |
| 29 | 'instance' => $this->reconcile->instance->value, | |
| 30 | 'keep' => $this->reconcile->keptAddresses->mapToList( | |
| 31 | static fn(ExposedEntityAddress $address): array => ['app' => $address->appId->value, 'key' => $address->key->value], | |
| 32 | ), | |
| 33 | 'keep_apps' => $this->reconcile->keptApps->toStrings(), | |
| 34 | ]; | |
| 35 | } | |
| 36 | } |