Passed
Push — master ( 4d2b9c...c2ed51 )
by Greg
06:41
created

RelationIsDescriptor::values()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 112
Code Lines 105

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 105
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 112
rs 8

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2021 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Elements;
21
22
use Fisharebest\Webtrees\I18N;
23
24
/**
25
 * RELATION_IS_DESCRIPTOR := {Size=1:25}
26
 * A word or phrase that states object 1's relation is object 2. For example
27
 * you would read the following as "Joe Jacob's great grandson is the submitter
28
 * pointed to by the @XREF:SUBM@":
29
 * 0 INDI
30
 * 1 NAME Joe /Jacob/
31
 * 1 ASSO @<XREF:SUBM>@
32
 * 2 RELA great grandson
33
 */
34
class RelationIsDescriptor extends AbstractElement
35
{
36
    protected const MAX_LENGTH = 25;
37
38
    /**
39
     * A list of controlled values for this element
40
     *
41
     * @param string $sex - the text depends on the sex of the *linked* individual
42
     *
43
     * @return array<int|string,string>
44
     */
45
    public function values(string $sex = 'U'): array
46
    {
47
        $values = [
48
            'M' => [
49
                ''                 => '',
50
                'attendant'        => I18N::translateContext('MALE', 'Attendant'),
51
                'attending'        => I18N::translateContext('MALE', 'Attending'),
52
                'best_man'         => I18N::translate('Best man'),
53
                'bridesmaid'       => I18N::translate('Bridesmaid'),
54
                'buyer'            => I18N::translateContext('MALE', 'Buyer'),
55
                'circumciser'      => I18N::translate('Circumciser'),
56
                'civil_registrar'  => I18N::translateContext('MALE', 'Civil registrar'),
57
                'employee'         => I18N::translateContext('MALE', 'Employee'),
58
                'employer'         => I18N::translateContext('MALE', 'Employer'),
59
                'foster_child'     => I18N::translate('Foster child'),
60
                'foster_father'    => I18N::translate('Foster father'),
61
                'foster_mother'    => I18N::translate('Foster mother'),
62
                'friend'           => I18N::translateContext('MALE', 'Friend'),
63
                'godfather'        => I18N::translate('Godfather'),
64
                'godmother'        => I18N::translate('Godmother'),
65
                'godparent'        => I18N::translate('Godparent'),
66
                'godson'           => I18N::translate('Godson'),
67
                'goddaughter'      => I18N::translate('Goddaughter'),
68
                'godchild'         => I18N::translate('Godchild'),
69
                'guardian'         => I18N::translateContext('MALE', 'Guardian'),
70
                'informant'        => I18N::translateContext('MALE', 'Informant'),
71
                'lodger'           => I18N::translateContext('MALE', 'Lodger'),
72
                'nanny'            => I18N::translate('Nanny'),
73
                'nurse'            => I18N::translateContext('MALE', 'Nurse'),
74
                'owner'            => I18N::translateContext('MALE', 'Owner'),
75
                'priest'           => I18N::translate('Priest'),
76
                'rabbi'            => I18N::translate('Rabbi'),
77
                'registry_officer' => I18N::translateContext('MALE', 'Registry officer'),
78
                'seller'           => I18N::translateContext('MALE', 'Seller'),
79
                'servant'          => I18N::translateContext('MALE', 'Servant'),
80
                'slave'            => I18N::translateContext('MALE', 'Slave'),
81
                'ward'             => I18N::translateContext('MALE', 'Ward'),
82
                'witness'          => I18N::translate('Witness'),
83
            ],
84
            'F' => [
85
                'attendant'        => I18N::translateContext('FEMALE', 'Attendant'),
86
                'attending'        => I18N::translateContext('FEMALE', 'Attending'),
87
                'best_man'         => I18N::translate('Best man'),
88
                'bridesmaid'       => I18N::translate('Bridesmaid'),
89
                'buyer'            => I18N::translateContext('FEMALE', 'Buyer'),
90
                'circumciser'      => I18N::translate('Circumciser'),
91
                'civil_registrar'  => I18N::translateContext('FEMALE', 'Civil registrar'),
92
                'employee'         => I18N::translateContext('FEMALE', 'Employee'),
93
                'employer'         => I18N::translateContext('FEMALE', 'Employer'),
94
                'foster_child'     => I18N::translate('Foster child'),
95
                'foster_father'    => I18N::translate('Foster father'),
96
                'foster_mother'    => I18N::translate('Foster mother'),
97
                'friend'           => I18N::translateContext('FEMALE', 'Friend'),
98
                'godfather'        => I18N::translate('Godfather'),
99
                'godmother'        => I18N::translate('Godmother'),
100
                'godparent'        => I18N::translate('Godparent'),
101
                'godson'           => I18N::translate('Godson'),
102
                'goddaughter'      => I18N::translate('Goddaughter'),
103
                'godchild'         => I18N::translate('Godchild'),
104
                'guardian'         => I18N::translateContext('FEMALE', 'Guardian'),
105
                'informant'        => I18N::translateContext('FEMALE', 'Informant'),
106
                'lodger'           => I18N::translateContext('FEMALE', 'Lodger'),
107
                'nanny'            => I18N::translate('Nanny'),
108
                'nurse'            => I18N::translateContext('FEMALE', 'Nurse'),
109
                'owner'            => I18N::translateContext('FEMALE', 'Owner'),
110
                'priest'           => I18N::translate('Priest'),
111
                'rabbi'            => I18N::translate('Rabbi'),
112
                'registry_officer' => I18N::translateContext('FEMALE', 'Registry officer'),
113
                'seller'           => I18N::translateContext('FEMALE', 'Seller'),
114
                'servant'          => I18N::translateContext('FEMALE', 'Servant'),
115
                'slave'            => I18N::translateContext('FEMALE', 'Slave'),
116
                'ward'             => I18N::translateContext('FEMALE', 'Ward'),
117
                'witness'          => I18N::translate('Witness'),
118
            ],
119
            'U' => [
120
                'attendant'        => I18N::translate('Attendant'),
121
                'attending'        => I18N::translate('Attending'),
122
                'best_man'         => I18N::translate('Best man'),
123
                'bridesmaid'       => I18N::translate('Bridesmaid'),
124
                'buyer'            => I18N::translate('Buyer'),
125
                'circumciser'      => I18N::translate('Circumciser'),
126
                'civil_registrar'  => I18N::translate('Civil registrar'),
127
                'employee'         => I18N::translate('Employee'),
128
                'employer'         => I18N::translate('Employer'),
129
                'foster_child'     => I18N::translate('Foster child'),
130
                'foster_father'    => I18N::translate('Foster father'),
131
                'foster_mother'    => I18N::translate('Foster mother'),
132
                'friend'           => I18N::translate('Friend'),
133
                'godfather'        => I18N::translate('Godfather'),
134
                'godmother'        => I18N::translate('Godmother'),
135
                'godparent'        => I18N::translate('Godparent'),
136
                'godson'           => I18N::translate('Godson'),
137
                'goddaughter'      => I18N::translate('Goddaughter'),
138
                'godchild'         => I18N::translate('Godchild'),
139
                'guardian'         => I18N::translate('Guardian'),
140
                'informant'        => I18N::translate('Informant'),
141
                'lodger'           => I18N::translate('Lodger'),
142
                'nanny'            => I18N::translate('Nanny'),
143
                'nurse'            => I18N::translate('Nurse'),
144
                'owner'            => I18N::translate('Owner'),
145
                'priest'           => I18N::translate('Priest'),
146
                'rabbi'            => I18N::translate('Rabbi'),
147
                'registry_officer' => I18N::translate('Registry officer'),
148
                'seller'           => I18N::translate('Seller'),
149
                'servant'          => I18N::translate('Servant'),
150
                'slave'            => I18N::translate('Slave'),
151
                'ward'             => I18N::translate('Ward'),
152
                'witness'          => I18N::translate('Witness'),
153
            ],
154
        ];
155
156
        return $values[$sex] ?? $values['U'];
157
    }
158
}
159