Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
85.71% covered (warning)
85.71%
18 / 21
85.71% covered (warning)
85.71%
6 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
Edition
85.71% covered (warning)
85.71%
18 / 21
85.71% covered (warning)
85.71%
6 / 7
15.66
0.00% covered (danger)
0.00%
0 / 1
 ontologyCommit
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 documentationCommit
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 apiVersion
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 dataModelVersion
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 codeListVersion
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 ontologyFolder
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 latest
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace LambdaTwelve\OneRecord\Spec;
6
7/**
8 * An endorsed release of the ONE Record standard: one API version, one data
9 * model version and one code-list version, published together by IATA as a
10 * tag of https://github.com/IATA-Cargo/ONE-Record.
11 *
12 * Adding a new edition is one case here plus one case in ApiVersion and, when
13 * the data model changed, DataModelVersion. Everything else (negotiation,
14 * server information, the vocabulary generator, the compliance matrix) reads
15 * from these enums, so nothing else needs to know a version string.
16 */
17enum Edition: string
18{
19    case E2025_07 = '2025-07';
20    case E2026_07 = '2026-07';
21
22    /**
23     * The commit the ontology files are read from. IATA cut both release tags
24     * while the ontologies still said "release candidate" and corrected the
25     * `<edition>-standard` folders on master afterwards (versionInfo "3.2"
26     * instead of "3.2-rc2", fixed labels and cardinalities), so the endorsed
27     * ontologies are pinned to that later master commit, not to the tag.
28     */
29    public function ontologyCommit(): string
30    {
31        return match ($this) {
32            self::E2025_07, self::E2026_07 => 'ad5f40d539b29692881672cf91878a4d2dbe59c2',
33        };
34    }
35
36    /**
37     * The commit the specification text and example bodies are read from:
38     * the release tag, whose documentation site is the endorsed edition.
39     */
40    public function documentationCommit(): string
41    {
42        return match ($this) {
43            self::E2025_07 => 'dfe7c38fbd104c4a85adfe1f6703c1ad87561928',
44            self::E2026_07 => '079490714c16ef7f73e12a6449a9f36e1cf1e06e',
45        };
46    }
47
48    public function apiVersion(): ApiVersion
49    {
50        return match ($this) {
51            self::E2025_07 => ApiVersion::V2_2_0,
52            self::E2026_07 => ApiVersion::V2_3_0,
53        };
54    }
55
56    public function dataModelVersion(): DataModelVersion
57    {
58        return match ($this) {
59            self::E2025_07 => DataModelVersion::V3_2,
60            self::E2026_07 => DataModelVersion::V3_3,
61        };
62    }
63
64    public function codeListVersion(): string
65    {
66        return match ($this) {
67            self::E2025_07, self::E2026_07 => '1.1.0',
68        };
69    }
70
71    /**
72     * Folder of the ontology files inside the IATA repository at this edition.
73     */
74    public function ontologyFolder(): string
75    {
76        return $this->value . '-standard';
77    }
78
79    public static function latest(): self
80    {
81        $cases = self::cases();
82
83        return $cases[\count($cases) - 1];
84    }
85}