Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Code Lines | 50 |
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 |
||
100 | public function canFindCollectionsBySettings(): void |
||
101 | { |
||
102 | $collectionsByLabel = $this->findCollectionsBySettings(['collections' => '1101, 1102']); |
||
103 | self::assertCount(2, $collectionsByLabel); |
||
104 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
105 | self::assertArrayHasKey('Musik', $collectionsByLabel); |
||
106 | |||
107 | $collectionsByLabel = $this->findCollectionsBySettings( |
||
108 | [ |
||
109 | 'index_name' => ['Geschichte', 'collection-with-single-document'], |
||
110 | 'show_userdefined' => true |
||
111 | ] |
||
112 | ); |
||
113 | self::assertCount(2, $collectionsByLabel); |
||
114 | self::assertArrayHasKey('Geschichte', $collectionsByLabel); |
||
115 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
116 | |||
117 | $collectionsByLabel = $this->findCollectionsBySettings(['show_userdefined' => true]); |
||
118 | self::assertCount(4, $collectionsByLabel); |
||
119 | self::assertArrayHasKey('Musik', $collectionsByLabel); |
||
120 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
121 | self::assertArrayHasKey('Geschichte', $collectionsByLabel); |
||
122 | self::assertArrayHasKey('Bildende Kunst', $collectionsByLabel); |
||
123 | self::assertEquals( |
||
124 | 'Bildende Kunst, Collection with single document, Geschichte, Musik', |
||
125 | implode(', ', array_keys($collectionsByLabel)) |
||
126 | ); |
||
127 | |||
128 | $collectionsByLabel = $this->findCollectionsBySettings(['show_userdefined' => false]); |
||
129 | self::assertCount(2, $collectionsByLabel); |
||
130 | self::assertArrayHasKey('Musik', $collectionsByLabel); |
||
131 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
132 | |||
133 | $collectionsByLabel = $this->findCollectionsBySettings(['hideEmptyOaiNames' => true]); |
||
134 | self::assertCount(2, $collectionsByLabel); |
||
135 | self::assertArrayHasKey('Musik', $collectionsByLabel); |
||
136 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
137 | |||
138 | $collectionsByLabel = $this->findCollectionsBySettings( |
||
139 | [ |
||
140 | 'hideEmptyOaiNames' => true, |
||
141 | 'show_userdefined' => true |
||
142 | ] |
||
143 | ); |
||
144 | self::assertCount(3, $collectionsByLabel); |
||
145 | self::assertArrayHasKey('Musik', $collectionsByLabel); |
||
146 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
147 | self::assertArrayHasKey('Geschichte', $collectionsByLabel); |
||
148 | |||
149 | $collectionsByLabel = $this->findCollectionsBySettings( |
||
150 | [ |
||
151 | 'hideEmptyOaiNames' => false, |
||
152 | 'show_userdefined' => true |
||
153 | ] |
||
154 | ); |
||
155 | self::assertCount(4, $collectionsByLabel); |
||
156 | self::assertArrayHasKey('Musik', $collectionsByLabel); |
||
157 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
158 | self::assertArrayHasKey('Geschichte', $collectionsByLabel); |
||
159 | self::assertArrayHasKey('Bildende Kunst', $collectionsByLabel); |
||
160 | |||
161 | $collectionsByLabel = $this->findCollectionsBySettings( |
||
162 | [ |
||
163 | 'collections' => '1101, 1102, 1103, 1104', |
||
164 | 'show_userdefined' => true, |
||
165 | 'hideEmptyOaiNames' => false, |
||
166 | 'index_name' => ['Geschichte', 'collection-with-single-document'] |
||
167 | ] |
||
168 | ); |
||
169 | |||
170 | self::assertCount(2, $collectionsByLabel); |
||
171 | self::assertArrayHasKey('Collection with single document', $collectionsByLabel); |
||
172 | self::assertArrayHasKey('Geschichte', $collectionsByLabel); |
||
173 | } |
||
202 |