Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.86% covered (success)
92.86%
13 / 14
88.89% covered (warning)
88.89%
8 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
IsCharacterSet
92.86% covered (success)
92.86%
13 / 14
88.89% covered (warning)
88.89%
8 / 9
12.05
0.00% covered (danger)
0.00%
0 / 1
 getFieldValue
n/a
0 / 0
n/a
0 / 0
0
 getData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPreferredMimeName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMibEnum
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSource
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReference
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 getAliases
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
 getNote
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 isActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\IanaValueObjects\CharacterSet;
3
4use Apie\Core\Lists\StringSet;
5use Apie\Core\ValueObjects\NonEmptyString;
6use Apie\Core\ValueObjects\Utils;
7
8trait IsCharacterSet
9{
10    abstract protected function getFieldValue(string $fieldName): mixed;
11
12    protected static function getData(): array
13    {
14        return require __DIR__ . '/../../fixtures/character-sets.php';
15    }
16
17    public function getPreferredMimeName(): string
18    {
19        return $this->getFieldValue('Preferred MIME Name');
20    }
21
22    public function getName(): string
23    {
24        return $this->getFieldValue('Name');
25    }
26
27    public function getMibEnum(): int
28    {
29        return Utils::toInt($this->getFieldValue('MIBenum'));
30    }
31
32    public function getSource(): string
33    {
34        return $this->getFieldValue('Source');
35    }
36
37    public function getReference(): ?NonEmptyString
38    {
39        $ref = $this->getFieldValue('Reference');
40        return $ref ? NonEmptyString::fromNative($ref) : null;
41    }
42
43    public function getAliases(): StringSet
44    {
45        $aliases = $this->getFieldValue('Aliases');
46        if (empty($aliases)) {
47            return new StringSet();
48        }
49
50        return new StringSet(explode("\n", $aliases));
51    }
52
53    public function getNote(): ?NonEmptyString
54    {
55        $note = $this->getFieldValue('Note');
56        return $note ? NonEmptyString::fromNative($note): null;
57    }
58
59    public function isActive(): bool
60    {
61        return (bool) $this->getFieldValue('Active');
62    }
63}