Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| InMemoryState | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace LambdaTwelve\OneRecord\Server\InMemory; |
| 6 | |
| 7 | use LambdaTwelve\OneRecord\Server\GrantAccessPolicy; |
| 8 | use LambdaTwelve\OneRecord\Server\Spi\Decision; |
| 9 | use Psr\Clock\ClockInterface; |
| 10 | |
| 11 | /** |
| 12 | * Every in-memory store of a server, together. It exists so a process can |
| 13 | * keep the state between requests: bin/serve runs under `php -S`, which |
| 14 | * starts PHP afresh for each request, and serialises this object to disk in |
| 15 | * between. The stores hold only value objects, so PHP's serializer suffices. |
| 16 | */ |
| 17 | final class InMemoryState |
| 18 | { |
| 19 | public readonly InMemoryLogisticsObjectStore $objects; |
| 20 | public readonly InMemoryLogisticsEventStore $events; |
| 21 | public readonly InMemoryActionRequestStore $actionRequests; |
| 22 | public readonly InMemorySubscriptionStore $subscriptions; |
| 23 | public readonly InMemoryAccessDelegationStore $delegations; |
| 24 | public readonly InMemoryNotificationOutbox $outbox; |
| 25 | public readonly GrantAccessPolicy $policy; |
| 26 | |
| 27 | public function __construct(ClockInterface $clock, Decision $denial = Decision::Forbid) |
| 28 | { |
| 29 | $this->objects = new InMemoryLogisticsObjectStore(); |
| 30 | $this->events = new InMemoryLogisticsEventStore(); |
| 31 | $this->actionRequests = new InMemoryActionRequestStore(); |
| 32 | $this->subscriptions = new InMemorySubscriptionStore($this->actionRequests); |
| 33 | $this->delegations = new InMemoryAccessDelegationStore(); |
| 34 | $this->outbox = new InMemoryNotificationOutbox(); |
| 35 | $this->policy = new GrantAccessPolicy($this->delegations, $clock, $denial); |
| 36 | } |
| 37 | } |