Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
DataLayerMetadata
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 withUpdatedMetadata
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\Datalayers;
3
4use DateTimeImmutable;
5
6final class DataLayerMetadata
7{
8    public private(set) string $etag;
9
10    public function __construct(
11        public readonly DateTimeImmutable $createdAt,
12        public readonly DateTimeImmutable $updatedAt,
13        public readonly string $createdInApieVersion,
14        public readonly string $updatedInApieVersion,
15    ) {
16        $this->etag = hash(
17            'sha256',
18            $this->updatedInApieVersion . ':' . $this->updatedAt->format('U.u')
19        );
20    }
21
22    public function withUpdatedMetadata(DateTimeImmutable $updatedAt, string $apieVersion): self
23    {
24        return new self(
25            $this->createdAt,
26            $updatedAt,
27            $this->createdInApieVersion,
28            $apieVersion
29        );
30    }
31}