Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
PublishResult
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 root
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 iris
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 changedAnything
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace LambdaTwelve\OneRecord\Server;
6
7use LambdaTwelve\OneRecord\Model\ResolvedGraph;
8use LambdaTwelve\OneRecord\Rdf\Iri;
9
10/**
11 * What publishing a graph did to each object, keyed by the host's local key.
12 */
13final readonly class PublishResult
14{
15    public const string CREATED = 'created';
16    public const string UPDATED = 'updated';
17    public const string UNCHANGED = 'unchanged';
18
19    /**
20     * @param array<string, self::CREATED|self::UPDATED|self::UNCHANGED> $outcomes
21     */
22    public function __construct(
23        public ResolvedGraph $graph,
24        public array $outcomes,
25    ) {}
26
27    public function root(): Iri
28    {
29        return $this->graph->root()->iri;
30    }
31
32    /**
33     * @return array<string, Iri>
34     */
35    public function iris(): array
36    {
37        return $this->graph->iris();
38    }
39
40    public function changedAnything(): bool
41    {
42        return array_filter($this->outcomes, static fn(string $o): bool => $o !== self::UNCHANGED) !== [];
43    }
44}