Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5namespace LambdaTwelve\OneRecord\Server\Spi;
6
7use DateTimeImmutable;
8use LambdaTwelve\OneRecord\Model\LogisticsObject;
9use LambdaTwelve\OneRecord\Rdf\Iri;
10
11/**
12 * Where logistics objects and their revisions live. Narrow on purpose so a
13 * relational implementation (one row per revision, the graph as JSON-LD) is
14 * straightforward, and transactional where it matters: saving revision N
15 * must fail if the current revision is not N-1.
16 */
17interface LogisticsObjectStore
18{
19    public function latest(Iri $iri): ?StoredObject;
20
21    public function revision(Iri $iri, int $revision): ?StoredObject;
22
23    /**
24     * The revision that was current at $at (the spec's ?at= query), or null
25     * if the object did not exist yet.
26     */
27    public function at(Iri $iri, DateTimeImmutable $at): ?StoredObject;
28
29    public function exists(Iri $iri): bool;
30
31    /**
32     * Revision 1.
33     *
34     * @throws StoreException ALREADY_EXISTS
35     */
36    public function create(LogisticsObject $object, DateTimeImmutable $at): StoredObject;
37
38    /**
39     * Revision $expectedCurrent + 1, only if $expectedCurrent is still current.
40     *
41     * @throws StoreException REVISION_CONFLICT, NOT_FOUND
42     */
43    public function saveRevision(LogisticsObject $object, int $expectedCurrent, DateTimeImmutable $at): StoredObject;
44
45    /**
46     * Removes every revision: the host's data-protection erasure. The API has
47     * no delete; this is for the host, after it has closed access.
48     */
49    public function erase(Iri $iri): void;
50}