Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Gender
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
6 / 6
22
100.00% covered (success)
100.00%
1 / 1
 getChoices
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 title
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 titleLong
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 salutation
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 text_1
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 text_2
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3declare(strict_types=1);
4
5namespace App\Type;
6
7enum Gender: string
8{
9    case male = '1';
10    case female = '2';
11    case other = '3';
12
13    /**
14     * @return array<string>
15     */
16    public static function getChoices(): array
17    {
18        $cases = [];
19
20        foreach (self::cases() as $case) {
21            $cases[$case->name] = $case->value;
22        }
23
24        return $cases;
25    }
26
27    // @TODO This should be translatable!
28    public function title(): string
29    {
30        return match ($this) {
31            self::male => 'Sr.',
32            self::female => 'Sra.',
33            self::other => 'Sr@.',
34        };
35    }
36
37    public function titleLong(): string
38    {
39        return match ($this) {
40            self::male => 'señor',
41            self::female => 'señora',
42            self::other => 'señor@',
43        };
44    }
45
46    public function salutation(): string
47    {
48        return match ($this) {
49            self::male => 'Estimado',
50            self::female => 'Estimada',
51            self::other => 'Estimad@',
52        };
53    }
54
55    public function text_1(): string
56    {
57        return match ($this) {
58            self::male => 'el',
59            self::female => 'la',
60            self::other => 'l@',
61        };
62    }
63
64    public function text_2(): string
65    {
66        return match ($this) {
67            self::male => 'del',
68            self::female => 'de la',
69            self::other => 'de l@',
70        };
71    }
72}