Conditions | 1 |
Paths | 1 |
Total Lines | 71 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
72 | public function getDataForTestMap(): iterable |
||
73 | { |
||
74 | yield 'numeric id' => [ |
||
75 | new Field('id', 1, new IdentifierField()), |
||
76 | 1, |
||
77 | ]; |
||
78 | |||
79 | yield 'remote_id md5' => [ |
||
80 | new Field( |
||
81 | 'remote_id', |
||
82 | '1611729231d469e6b53c431f476926ac', |
||
83 | new IdentifierField() |
||
84 | ), |
||
85 | '1611729231d469e6b53c431f476926ac', |
||
86 | ]; |
||
87 | |||
88 | yield 'external remote_id' => [ |
||
89 | new Field( |
||
90 | 'location_remote_id', |
||
91 | 'external:10', |
||
92 | new IdentifierField() |
||
93 | ), |
||
94 | 'external:10', |
||
95 | ]; |
||
96 | |||
97 | yield 'section identifier' => [ |
||
98 | new Field( |
||
99 | 'section_identifier', |
||
100 | 'my_section', |
||
101 | new IdentifierField() |
||
102 | ), |
||
103 | 'my_section', |
||
104 | ]; |
||
105 | |||
106 | yield 'path string' => [ |
||
107 | new Field( |
||
108 | 'path_string', |
||
109 | '/1/2/54/', |
||
110 | new IdentifierField() |
||
111 | ), |
||
112 | '/1/2/54/', |
||
113 | ]; |
||
114 | |||
115 | yield 'identifier with national characters' => [ |
||
116 | new Field( |
||
117 | 'some_identifier', |
||
118 | 'zażółć gęślą jaźń', |
||
119 | new IdentifierField() |
||
120 | ), |
||
121 | 'zażółć gęślą jaźń', |
||
122 | ]; |
||
123 | |||
124 | yield 'identifier with non-printable characters' => [ |
||
125 | new Field( |
||
126 | 'identifier', |
||
127 | utf8_decode("Non\x09Printable\x0EIdentifier"), |
||
128 | new IdentifierField() |
||
129 | ), |
||
130 | 'Non PrintableIdentifier', |
||
131 | ]; |
||
132 | |||
133 | $value = 'Emoji: ' . json_decode('"\ud83d\ude00"'); |
||
134 | yield 'identifier with emojis' => [ |
||
135 | new Field( |
||
136 | 'identifier', |
||
137 | $value, |
||
138 | new IdentifierField() |
||
139 | ), |
||
140 | $value, |
||
141 | ]; |
||
142 | } |
||
143 | } |
||
144 |