Completed
Push — develop ( 0d6c46...c341e4 )
by Greg
15:25 queued 09:07
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) 2020 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 <http://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\GedcomElements;
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
    /**
37
     * A list of controlled values for this element
38
     *
39
     * @param string $sex - the text depends on the sex of the *linked* individual
40
     *
41
     * @return array<int|string,string>
42
     */
43
    public function values(string $sex = 'U'): array
44
    {
45
        $values = [
46
            'M' => [
47
                ''                 => '',
48
                'attendant'        => I18N::translateContext('MALE', 'Attendant'),
49
                'attending'        => I18N::translateContext('MALE', 'Attending'),
50
                'best_man'         => I18N::translate('Best man'),
51
                'bridesmaid'       => I18N::translate('Bridesmaid'),
52
                'buyer'            => I18N::translateContext('MALE', 'Buyer'),
53
                'circumciser'      => I18N::translate('Circumciser'),
54
                'civil_registrar'  => I18N::translateContext('MALE', 'Civil registrar'),
55
                'employee'         => I18N::translateContext('MALE', 'Employee'),
56
                'employer'         => I18N::translateContext('MALE', 'Employer'),
57
                'foster_child'     => I18N::translate('Foster child'),
58
                'foster_father'    => I18N::translate('Foster father'),
59
                'foster_mother'    => I18N::translate('Foster mother'),
60
                'friend'           => I18N::translateContext('MALE', 'Friend'),
61
                'godfather'        => I18N::translate('Godfather'),
62
                'godmother'        => I18N::translate('Godmother'),
63
                'godparent'        => I18N::translate('Godparent'),
64
                'godson'           => I18N::translate('Godson'),
65
                'goddaughter'      => I18N::translate('Goddaughter'),
66
                'godchild'         => I18N::translate('Godchild'),
67
                'guardian'         => I18N::translateContext('MALE', 'Guardian'),
68
                'informant'        => I18N::translateContext('MALE', 'Informant'),
69
                'lodger'           => I18N::translateContext('MALE', 'Lodger'),
70
                'nanny'            => I18N::translate('Nanny'),
71
                'nurse'            => I18N::translateContext('MALE', 'Nurse'),
72
                'owner'            => I18N::translateContext('MALE', 'Owner'),
73
                'priest'           => I18N::translate('Priest'),
74
                'rabbi'            => I18N::translate('Rabbi'),
75
                'registry_officer' => I18N::translateContext('MALE', 'Registry officer'),
76
                'seller'           => I18N::translateContext('MALE', 'Seller'),
77
                'servant'          => I18N::translateContext('MALE', 'Servant'),
78
                'slave'            => I18N::translateContext('MALE', 'Slave'),
79
                'ward'             => I18N::translateContext('MALE', 'Ward'),
80
                'witness'          => I18N::translate('Witness'),
81
            ],
82
            'F' => [
83
                'attendant'        => I18N::translateContext('FEMALE', 'Attendant'),
84
                'attending'        => I18N::translateContext('FEMALE', 'Attending'),
85
                'best_man'         => I18N::translate('Best man'),
86
                'bridesmaid'       => I18N::translate('Bridesmaid'),
87
                'buyer'            => I18N::translateContext('FEMALE', 'Buyer'),
88
                'circumciser'      => I18N::translate('Circumciser'),
89
                'civil_registrar'  => I18N::translateContext('FEMALE', 'Civil registrar'),
90
                'employee'         => I18N::translateContext('FEMALE', 'Employee'),
91
                'employer'         => I18N::translateContext('FEMALE', 'Employer'),
92
                'foster_child'     => I18N::translate('Foster child'),
93
                'foster_father'    => I18N::translate('Foster father'),
94
                'foster_mother'    => I18N::translate('Foster mother'),
95
                'friend'           => I18N::translateContext('FEMALE', 'Friend'),
96
                'godfather'        => I18N::translate('Godfather'),
97
                'godmother'        => I18N::translate('Godmother'),
98
                'godparent'        => I18N::translate('Godparent'),
99
                'godson'           => I18N::translate('Godson'),
100
                'goddaughter'      => I18N::translate('Goddaughter'),
101
                'godchild'         => I18N::translate('Godchild'),
102
                'guardian'         => I18N::translateContext('FEMALE', 'Guardian'),
103
                'informant'        => I18N::translateContext('FEMALE', 'Informant'),
104
                'lodger'           => I18N::translateContext('FEMALE', 'Lodger'),
105
                'nanny'            => I18N::translate('Nanny'),
106
                'nurse'            => I18N::translateContext('FEMALE', 'Nurse'),
107
                'owner'            => I18N::translateContext('FEMALE', 'Owner'),
108
                'priest'           => I18N::translate('Priest'),
109
                'rabbi'            => I18N::translate('Rabbi'),
110
                'registry_officer' => I18N::translateContext('FEMALE', 'Registry officer'),
111
                'seller'           => I18N::translateContext('FEMALE', 'Seller'),
112
                'servant'          => I18N::translateContext('FEMALE', 'Servant'),
113
                'slave'            => I18N::translateContext('FEMALE', 'Slave'),
114
                'ward'             => I18N::translateContext('FEMALE', 'Ward'),
115
                'witness'          => I18N::translate('Witness'),
116
            ],
117
            'U' => [
118
                'attendant'        => I18N::translate('Attendant'),
119
                'attending'        => I18N::translate('Attending'),
120
                'best_man'         => I18N::translate('Best man'),
121
                'bridesmaid'       => I18N::translate('Bridesmaid'),
122
                'buyer'            => I18N::translate('Buyer'),
123
                'circumciser'      => I18N::translate('Circumciser'),
124
                'civil_registrar'  => I18N::translate('Civil registrar'),
125
                'employee'         => I18N::translate('Employee'),
126
                'employer'         => I18N::translate('Employer'),
127
                'foster_child'     => I18N::translate('Foster child'),
128
                'foster_father'    => I18N::translate('Foster father'),
129
                'foster_mother'    => I18N::translate('Foster mother'),
130
                'friend'           => I18N::translate('Friend'),
131
                'godfather'        => I18N::translate('Godfather'),
132
                'godmother'        => I18N::translate('Godmother'),
133
                'godparent'        => I18N::translate('Godparent'),
134
                'godson'           => I18N::translate('Godson'),
135
                'goddaughter'      => I18N::translate('Goddaughter'),
136
                'godchild'         => I18N::translate('Godchild'),
137
                'guardian'         => I18N::translate('Guardian'),
138
                'informant'        => I18N::translate('Informant'),
139
                'lodger'           => I18N::translate('Lodger'),
140
                'nanny'            => I18N::translate('Nanny'),
141
                'nurse'            => I18N::translate('Nurse'),
142
                'owner'            => I18N::translate('Owner'),
143
                'priest'           => I18N::translate('Priest'),
144
                'rabbi'            => I18N::translate('Rabbi'),
145
                'registry_officer' => I18N::translate('Registry officer'),
146
                'seller'           => I18N::translate('Seller'),
147
                'servant'          => I18N::translate('Servant'),
148
                'slave'            => I18N::translate('Slave'),
149
                'ward'             => I18N::translate('Ward'),
150
                'witness'          => I18N::translate('Witness'),
151
            ],
152
        ];
153
154
        return $values[$sex] ?? $values['U'];
155
    }
156
}
157