Conditions | 2 |
Paths | 2 |
Total Lines | 58 |
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 |
||
29 | public function providerForTestBuild(): array |
||
30 | { |
||
31 | $versionStatuses = [ |
||
32 | VersionInfo::STATUS_DRAFT, |
||
33 | VersionInfo::STATUS_PUBLISHED, |
||
34 | VersionInfo::STATUS_ARCHIVED, |
||
35 | ]; |
||
36 | |||
37 | $data = []; |
||
38 | foreach ($versionStatuses as $versionStatus) { |
||
39 | $languagesList = ['ger-DE', 'eng-US', 'eng-GB']; |
||
40 | $contentTypeIdsList = ['1', '2']; |
||
41 | $initialLanguageCode = 'eng-US'; |
||
42 | $fields = [ |
||
43 | new Field(['languageCode' => 'ger-DE']), |
||
44 | new Field(['languageCode' => 'ger-DE']), |
||
45 | new Field(['languageCode' => 'eng-US']), |
||
46 | ]; |
||
47 | $updateTranslationsLanguageCodes = ['ger-DE', 'eng-US']; |
||
48 | |||
49 | $data[] = [ |
||
50 | new Target\Version( |
||
51 | [ |
||
52 | 'newStatus' => $versionStatus, |
||
53 | 'allLanguageCodesList' => $languagesList, |
||
54 | 'allContentTypeIdsList' => $contentTypeIdsList, |
||
55 | 'forUpdateLanguageCodesList' => $updateTranslationsLanguageCodes, |
||
56 | 'forUpdateInitialLanguageCode' => $initialLanguageCode, |
||
57 | ] |
||
58 | ), |
||
59 | $versionStatus, |
||
60 | $initialLanguageCode, |
||
61 | $fields, |
||
62 | $languagesList, |
||
63 | $contentTypeIdsList, |
||
64 | ]; |
||
65 | |||
66 | // no published content |
||
67 | $data[] = [ |
||
68 | new Target\Version( |
||
69 | [ |
||
70 | 'newStatus' => $versionStatus, |
||
71 | 'allLanguageCodesList' => $languagesList, |
||
72 | 'allContentTypeIdsList' => $contentTypeIdsList, |
||
73 | 'forUpdateLanguageCodesList' => $updateTranslationsLanguageCodes, |
||
74 | 'forUpdateInitialLanguageCode' => $initialLanguageCode, |
||
75 | ] |
||
76 | ), |
||
77 | $versionStatus, |
||
78 | $initialLanguageCode, |
||
79 | $fields, |
||
80 | $languagesList, |
||
81 | $contentTypeIdsList, |
||
82 | ]; |
||
83 | } |
||
84 | |||
85 | return $data; |
||
86 | } |
||
87 | |||
121 |