Conditions | 12 |
Paths | 21 |
Total Lines | 43 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
40 | private function generateFromInternalFile(int $example): void |
||
41 | { |
||
42 | $exampleDirectory = __DIR__.'/examples'; |
||
43 | |||
44 | switch ($example) { |
||
45 | case Type::MALE_40K_ARCHAIC: |
||
46 | $handle = fopen($exampleDirectory.'/40k_male_archaic.csv', 'r'); |
||
47 | break; |
||
48 | case Type::MALE_40K_LOWER_GOTHIC: |
||
49 | $handle = fopen($exampleDirectory.'/40k_male_lower_gothic.csv', 'r'); |
||
50 | break; |
||
51 | case Type::MALE_40K_HIGHER_GOTHIC: |
||
52 | $handle = fopen($exampleDirectory.'/40k_male_higher_gothic.csv', 'r'); |
||
53 | break; |
||
54 | case Type::MALE_40K_PRIMITIVE: |
||
55 | $handle = fopen($exampleDirectory.'/40k_male_primitive.csv', 'r'); |
||
56 | break; |
||
57 | case Type::FEMALE_40K_ARCHAIC: |
||
58 | $handle = fopen($exampleDirectory.'/40k_female_archaic.csv', 'r'); |
||
59 | break; |
||
60 | case Type::FEMALE_40K_LOWER_GOTHIC: |
||
61 | $handle = fopen($exampleDirectory.'/40k_female_lower_gothic.csv', 'r'); |
||
62 | break; |
||
63 | case Type::FEMALE_40K_HIGHER_GOTHIC: |
||
64 | $handle = fopen($exampleDirectory.'/40k_female_higher_gothic.csv', 'r'); |
||
65 | break; |
||
66 | case Type::FEMALE_40K_PRIMITIVE: |
||
67 | $handle = fopen($exampleDirectory.'/40k_female_primitive.csv', 'r'); |
||
68 | break; |
||
69 | case Type::MALE_ELVES: |
||
70 | $handle = fopen($exampleDirectory.'/male_elves.csv', 'r'); |
||
71 | break; |
||
72 | case Type::FEMALE_ELVES: |
||
73 | $handle = fopen($exampleDirectory.'/female_elves.csv', 'r'); |
||
74 | break; |
||
75 | default: |
||
76 | throw new GenerateFromFileException(sprintf('There is no file configured for ID %s', $example)); |
||
77 | } |
||
78 | |||
79 | while (($data = fgetcsv($handle)) !== false) { |
||
80 | $this->nameList[] = $data[0]; |
||
81 | } |
||
82 | fclose($handle); |
||
83 | } |
||
203 | } |