Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
17 / 17
CRAP
100.00% covered (success)
100.00%
1 / 1
IanaObject
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
17 / 17
19
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
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCharsetPreferredMimeName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCharsetName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCharsetMibEnum
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCharsetSource
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCharsetReference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCharsetAliases
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
 getCharsetNote
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHeaderFieldName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHeaderStatus
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHeaderStructuredType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHeaderReference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHeaderComments
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStatusValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStatusDescription
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStatusReference
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\IntegrationTests\Apie\TypeDemo\Resources;
3
4use Apie\Core\Entities\EntityInterface;
5use Apie\Core\Lists\StringSet;
6use Apie\Core\ValueObjects\NonEmptyString;
7use Apie\IanaValueObjects\CharacterSet\ActiveCharacterSet;
8use Apie\IanaValueObjects\CharacterSet\CharacterSet;
9use Apie\IanaValueObjects\HttpHeader\ActiveHttpHeader;
10use Apie\IanaValueObjects\HttpHeader\HttpHeader;
11use Apie\IanaValueObjects\HttpHeader\HttpHeaderStatus;
12use Apie\IanaValueObjects\HttpHeader\StructuredType;
13use Apie\IanaValueObjects\HttpStatus\ActiveHttpStatus;
14use Apie\IanaValueObjects\HttpStatus\HttpStatus;
15use Apie\IanaValueObjects\LanguageTag\ActiveLanguage;
16use Apie\IanaValueObjects\LanguageTag\Language;
17use Apie\IanaValueObjects\MediaType\ActiveMediaType;
18use Apie\IanaValueObjects\MediaType\MediaType;
19use Apie\IanaValueObjects\PortNumber\ActivePortNumber;
20use Apie\IanaValueObjects\PortNumber\PortNumber;
21use Apie\IanaValueObjects\TopLevelDomain\ActiveTopLevelDomain;
22use Apie\IanaValueObjects\TopLevelDomain\TopLevelDomain;
23use Apie\IanaValueObjects\UriScheme\ActiveUriScheme;
24use Apie\IanaValueObjects\UriScheme\UriScheme;
25use Apie\IntegrationTests\Apie\TypeDemo\Identifiers\IanaObjectIdentifier;
26
27class IanaObject implements EntityInterface
28{
29    private IanaObjectIdentifier $id;
30
31    public function __construct(
32        public ?CharacterSet $set = null,
33        public ?ActiveCharacterSet $activeSet = null,
34        public ?HttpHeader $header = null,
35        public ?ActiveHttpHeader $activeHeader = null,
36        public ?HttpStatus $status = null,
37        public ?ActiveHttpStatus $activeHttpStatus = null,
38        public ?Language $language = null,
39        public ?ActiveLanguage $activeLanguage = null,
40        public ?MediaType $mediaType = null,
41        public ?ActiveMediaType $activeMediaType = null,
42        public ?PortNumber $portNumber = null,
43        public ?ActivePortNumber $activePortNumber = null,
44        public ?TopLevelDomain $topLevelDomain = null,
45        public ?ActiveTopLevelDomain $activeTopLevelDomain = null,
46        public ?UriScheme $scheme = null,
47        public ?ActiveUriScheme $activeScheme = null,
48    ) {
49        $this->id = IanaObjectIdentifier::createRandom();
50    }
51
52    public function getId(): IanaObjectIdentifier
53    {
54        return $this->id;
55    }
56
57    public function getCharsetPreferredMimeName(): string
58    {
59        return $this->set?->getPreferredMimeName() ?? $this->activeSet?->getPreferredMimeName() ?? 'Missing';
60    }
61
62    public function getCharsetName(): string
63    {
64        return $this->set?->getName() ?? $this->activeSet?->getName() ?? 'Missing';
65    }
66
67    public function getCharsetMibEnum(): ?int
68    {
69        return $this->set?->getMibEnum() ?? $this->activeSet?->getMibEnum() ?? null;
70    }
71
72    public function getCharsetSource(): string
73    {
74        return $this->set?->getSource() ?? $this->activeSet?->getSource() ?? 'Missing';
75    }
76
77    public function getCharsetReference(): ?NonEmptyString
78    {
79        return $this->set?->getReference() ?? $this->activeSet?->getReference() ?? null;
80    }
81
82    public function getCharsetAliases(): StringSet
83    {
84        $list = [];
85        foreach ($this->set?->getAliases() ?? [] as $option) {
86            $list[] = $option;
87        }
88        foreach ($this->activeSet?->getAliases() ?? [] as $option) {
89            $list[] = $option;
90        }
91
92        return new StringSet($list);
93    }
94
95    public function getCharsetNote(): ?NonEmptyString
96    {
97        return $this->set?->getNote() ?? $this->activeSet?->getNote() ?? null;
98    }
99
100    public function getHeaderFieldName(): string
101    {
102        return $this->header?->getFieldName() ?? $this->activeHeader?->getFieldName() ?? 'missing';
103    }
104
105    public function getHeaderStatus(): ?HttpHeaderStatus
106    {
107        return $this->header?->getStatus() ?? $this->activeHeader?->getStatus() ?? null;
108    }
109
110    public function getHeaderStructuredType(): ?StructuredType
111    {
112        return $this->header?->getStructuredType() ?? $this->activeHeader?->getStructuredType() ?? null;
113    }
114
115    public function getHeaderReference(): string
116    {
117        return $this->header?->getReference() ?? $this->activeHeader?->getReference() ?? 'Missing';
118    }
119
120    public function getHeaderComments(): ?NonEmptyString
121    {
122        return $this->header?->getComments() ?? $this->activeHeader?->getComments() ?? null;
123    }
124
125    public function getStatusValue(): string
126    {
127        return $this->status?->getValue() ?? $this->activeHttpStatus?->getValue() ?? 'Missing';
128    }
129
130    public function getStatusDescription(): string
131    {
132        return $this->status?->getDescription() ?? $this->activeHttpStatus?->getDescription() ?? 'Missing';
133    }
134
135    public function getStatusReference(): ?NonEmptyString
136    {
137        return $this->status?->getReference() ?? $this->activeHttpStatus?->getReference() ?? null;
138    }
139}