Passed
Push — master ( 4e4594...2165e8 )
by Aimeos
05:28
created
lib/mwlib/tests/MW/MapTest.php 1 patch
Spacing   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -14,350 +14,350 @@  discard block
 block discarded – undo
14 14
 {
15 15
 	public function testFirstReturnsFirstItemInMap()
16 16
 	{
17
-		$c = new Map(['foo', 'bar']);
18
-		$this->assertEquals('foo', $c->first());
17
+		$c = new Map( ['foo', 'bar'] );
18
+		$this->assertEquals( 'foo', $c->first() );
19 19
 	}
20 20
 
21 21
 	public function testFirstWithCallback()
22 22
 	{
23
-		$data = new Map(['foo', 'bar', 'baz']);
23
+		$data = new Map( ['foo', 'bar', 'baz'] );
24 24
 		$result = $data->first( function( $value ) {
25 25
 			return $value === 'bar';
26 26
 		} );
27
-		$this->assertEquals('bar', $result);
27
+		$this->assertEquals( 'bar', $result );
28 28
 	}
29 29
 
30 30
 	public function testFirstWithCallbackAndDefault()
31 31
 	{
32
-		$data = new Map(['foo', 'bar']);
32
+		$data = new Map( ['foo', 'bar'] );
33 33
 		$result = $data->first( function( $value ) {
34 34
 			return $value === 'baz';
35 35
 		}, 'default' );
36
-		$this->assertEquals('default', $result);
36
+		$this->assertEquals( 'default', $result );
37 37
 	}
38 38
 
39 39
 	public function testFirstWithDefaultAndWithoutCallback()
40 40
 	{
41 41
 		$data = new Map;
42
-		$result = $data->first(null, 'default');
43
-		$this->assertEquals('default', $result);
42
+		$result = $data->first( null, 'default' );
43
+		$this->assertEquals( 'default', $result );
44 44
 	}
45 45
 
46 46
 	public function testLastReturnsLastItemInMap()
47 47
 	{
48
-		$c = new Map(['foo', 'bar']);
49
-		$this->assertEquals('bar', $c->last());
48
+		$c = new Map( ['foo', 'bar'] );
49
+		$this->assertEquals( 'bar', $c->last() );
50 50
 	}
51 51
 
52 52
 	public function testLastWithCallback()
53 53
 	{
54
-		$data = new Map([100, 200, 300]);
54
+		$data = new Map( [100, 200, 300] );
55 55
 		$result = $data->last( function( $value ) {
56 56
 			return $value < 250;
57 57
 		} );
58
-		$this->assertEquals(200, $result);
58
+		$this->assertEquals( 200, $result );
59 59
 		$result = $data->last( function( $value, $key ) {
60 60
 			return $key < 2;
61 61
 		} );
62
-		$this->assertEquals(200, $result);
62
+		$this->assertEquals( 200, $result );
63 63
 	}
64 64
 
65 65
 	public function testLastWithCallbackAndDefault()
66 66
 	{
67
-		$data = new Map(['foo', 'bar']);
67
+		$data = new Map( ['foo', 'bar'] );
68 68
 		$result = $data->last( function( $value ) {
69 69
 			return $value === 'baz';
70 70
 		}, 'default' );
71
-		$this->assertEquals('default', $result);
71
+		$this->assertEquals( 'default', $result );
72 72
 	}
73 73
 
74 74
 	public function testLastWithDefaultAndWithoutCallback()
75 75
 	{
76 76
 		$data = new Map;
77
-		$result = $data->last(null, 'default');
78
-		$this->assertEquals('default', $result);
77
+		$result = $data->last( null, 'default' );
78
+		$this->assertEquals( 'default', $result );
79 79
 	}
80 80
 
81 81
 	public function testPopReturnsAndRemovesLastItemInMap()
82 82
 	{
83
-		$c = new Map(['foo', 'bar']);
83
+		$c = new Map( ['foo', 'bar'] );
84 84
 
85
-		$this->assertEquals('bar', $c->pop());
86
-		$this->assertEquals('foo', $c->first());
85
+		$this->assertEquals( 'bar', $c->pop() );
86
+		$this->assertEquals( 'foo', $c->first() );
87 87
 	}
88 88
 
89 89
 	public function testShiftReturnsAndRemovesFirstItemInMap()
90 90
 	{
91
-		$c = new Map(['foo', 'bar']);
91
+		$c = new Map( ['foo', 'bar'] );
92 92
 
93
-		$this->assertEquals('foo', $c->shift());
94
-		$this->assertEquals('bar', $c->first());
93
+		$this->assertEquals( 'foo', $c->shift() );
94
+		$this->assertEquals( 'bar', $c->first() );
95 95
 	}
96 96
 
97 97
 	public function testEmptyMapIsEmpty()
98 98
 	{
99 99
 		$c = new Map;
100 100
 
101
-		$this->assertTrue($c->isEmpty());
101
+		$this->assertTrue( $c->isEmpty() );
102 102
 	}
103 103
 
104 104
 	public function testMapIsConstructed()
105 105
 	{
106 106
 		$map = new Map;
107
-		$this->assertEmpty($map->toArray());
107
+		$this->assertEmpty( $map->toArray() );
108 108
 	}
109 109
 
110 110
 	public function testMapShuffle()
111 111
 	{
112
-		$map = new Map(range(0, 100, 10));
112
+		$map = new Map( range( 0, 100, 10 ) );
113 113
 
114 114
 		$firstRandom = $map->copy()->shuffle();
115 115
 		$secondRandom = $map->copy()->shuffle();
116 116
 
117
-		$this->assertNotEquals($firstRandom, $secondRandom);
117
+		$this->assertNotEquals( $firstRandom, $secondRandom );
118 118
 	}
119 119
 
120 120
 	public function testGetArray()
121 121
 	{
122 122
 		$map = new Map;
123 123
 
124
-		$class = new \ReflectionClass($map);
125
-		$method = $class->getMethod('getArray');
126
-		$method->setAccessible(true);
124
+		$class = new \ReflectionClass( $map );
125
+		$method = $class->getMethod( 'getArray' );
126
+		$method->setAccessible( true );
127 127
 
128
-		$items = new \ArrayIterator( ['foo' => 'bar']);
129
-		$array = $method->invokeArgs($map, [$items]);
130
-		$this->assertSame(['foo' => 'bar'], $array);
128
+		$items = new \ArrayIterator( ['foo' => 'bar'] );
129
+		$array = $method->invokeArgs( $map, [$items] );
130
+		$this->assertSame( ['foo' => 'bar'], $array );
131 131
 
132
-		$items = new Map(['foo' => 'bar']);
133
-		$array = $method->invokeArgs($map, [$items]);
134
-		$this->assertSame(['foo' => 'bar'], $array);
132
+		$items = new Map( ['foo' => 'bar'] );
133
+		$array = $method->invokeArgs( $map, [$items] );
134
+		$this->assertSame( ['foo' => 'bar'], $array );
135 135
 
136 136
 		$items = ['foo' => 'bar'];
137
-		$array = $method->invokeArgs($map, [$items]);
138
-		$this->assertSame(['foo' => 'bar'], $array);
137
+		$array = $method->invokeArgs( $map, [$items] );
138
+		$this->assertSame( ['foo' => 'bar'], $array );
139 139
 	}
140 140
 
141 141
 	public function testOffsetAccess()
142 142
 	{
143
-		$c = new Map(['name' => 'test']);
144
-		$this->assertEquals('test', $c['name']);
143
+		$c = new Map( ['name' => 'test'] );
144
+		$this->assertEquals( 'test', $c['name'] );
145 145
 		$c['name'] = 'me';
146
-		$this->assertEquals('me', $c['name']);
147
-		$this->assertTrue(isset($c['name']));
148
-		unset($c['name']);
149
-		$this->assertFalse(isset($c['name']));
146
+		$this->assertEquals( 'me', $c['name'] );
147
+		$this->assertTrue( isset( $c['name'] ) );
148
+		unset( $c['name'] );
149
+		$this->assertFalse( isset( $c['name'] ) );
150 150
 		$c[] = 'jason';
151
-		$this->assertEquals('jason', $c[0]);
151
+		$this->assertEquals( 'jason', $c[0] );
152 152
 	}
153 153
 
154 154
 	public function testArrayAccessOffsetExists()
155 155
 	{
156
-		$c = new Map(['foo', 'bar']);
157
-		$this->assertTrue($c->offsetExists(0));
158
-		$this->assertTrue($c->offsetExists(1));
159
-		$this->assertFalse($c->offsetExists(1000));
156
+		$c = new Map( ['foo', 'bar'] );
157
+		$this->assertTrue( $c->offsetExists( 0 ) );
158
+		$this->assertTrue( $c->offsetExists( 1 ) );
159
+		$this->assertFalse( $c->offsetExists( 1000 ) );
160 160
 	}
161 161
 
162 162
 	public function testArrayAccessOffsetGet()
163 163
 	{
164
-		$c = new Map(['foo', 'bar']);
165
-		$this->assertEquals('foo', $c->offsetGet(0));
166
-		$this->assertEquals('bar', $c->offsetGet(1));
164
+		$c = new Map( ['foo', 'bar'] );
165
+		$this->assertEquals( 'foo', $c->offsetGet( 0 ) );
166
+		$this->assertEquals( 'bar', $c->offsetGet( 1 ) );
167 167
 	}
168 168
 
169 169
 	public function testArrayAccessOffsetSet()
170 170
 	{
171
-		$c = new Map(['foo', 'foo']);
171
+		$c = new Map( ['foo', 'foo'] );
172 172
 
173
-		$c->offsetSet(1, 'bar');
174
-		$this->assertEquals('bar', $c[1]);
173
+		$c->offsetSet( 1, 'bar' );
174
+		$this->assertEquals( 'bar', $c[1] );
175 175
 
176
-		$c->offsetSet(null, 'qux');
177
-		$this->assertEquals('qux', $c[2]);
176
+		$c->offsetSet( null, 'qux' );
177
+		$this->assertEquals( 'qux', $c[2] );
178 178
 	}
179 179
 
180 180
 	public function testArrayAccessOffsetUnset()
181 181
 	{
182
-		$c = new Map(['foo', 'bar']);
182
+		$c = new Map( ['foo', 'bar'] );
183 183
 
184
-		$c->offsetUnset(1);
185
-		$this->assertFalse(isset($c[1]));
184
+		$c->offsetUnset( 1 );
185
+		$this->assertFalse( isset( $c[1] ) );
186 186
 	}
187 187
 
188 188
 	public function testRemoveSingleKey()
189 189
 	{
190
-		$c = new Map(['foo', 'bar']);
191
-		$c->remove(0);
192
-		$this->assertFalse(isset($c['foo']));
190
+		$c = new Map( ['foo', 'bar'] );
191
+		$c->remove( 0 );
192
+		$this->assertFalse( isset( $c['foo'] ) );
193 193
 
194
-		$c = new Map(['foo' => 'bar', 'baz' => 'qux']);
195
-		$c->remove('foo');
196
-		$this->assertFalse(isset($c['foo']));
194
+		$c = new Map( ['foo' => 'bar', 'baz' => 'qux'] );
195
+		$c->remove( 'foo' );
196
+		$this->assertFalse( isset( $c['foo'] ) );
197 197
 	}
198 198
 
199 199
 	public function testRemoveArrayOfKeys()
200 200
 	{
201
-		$c = new Map(['foo', 'bar', 'baz']);
202
-		$c->remove([0, 2]);
203
-		$this->assertFalse(isset($c[0]));
204
-		$this->assertFalse(isset($c[2]));
205
-		$this->assertTrue(isset($c[1]));
201
+		$c = new Map( ['foo', 'bar', 'baz'] );
202
+		$c->remove( [0, 2] );
203
+		$this->assertFalse( isset( $c[0] ) );
204
+		$this->assertFalse( isset( $c[2] ) );
205
+		$this->assertTrue( isset( $c[1] ) );
206 206
 
207
-		$c = new Map(['name' => 'test', 'foo' => 'bar', 'baz' => 'qux']);
208
-		$c->remove(['foo', 'baz']);
209
-		$this->assertFalse(isset($c['foo']));
210
-		$this->assertFalse(isset($c['baz']));
211
-		$this->assertTrue(isset($c['name']));
207
+		$c = new Map( ['name' => 'test', 'foo' => 'bar', 'baz' => 'qux'] );
208
+		$c->remove( ['foo', 'baz'] );
209
+		$this->assertFalse( isset( $c['foo'] ) );
210
+		$this->assertFalse( isset( $c['baz'] ) );
211
+		$this->assertTrue( isset( $c['name'] ) );
212 212
 	}
213 213
 
214 214
 	public function testCountable()
215 215
 	{
216
-		$c = new Map(['foo', 'bar']);
217
-		$this->assertCount(2, $c);
216
+		$c = new Map( ['foo', 'bar'] );
217
+		$this->assertCount( 2, $c );
218 218
 	}
219 219
 
220 220
 	public function testIterable()
221 221
 	{
222
-		$c = new Map(['foo']);
223
-		$this->assertInstanceOf(\ArrayIterator::class, $c->getIterator());
224
-		$this->assertEquals(['foo'], $c->getIterator()->getArrayCopy());
222
+		$c = new Map( ['foo'] );
223
+		$this->assertInstanceOf( \ArrayIterator::class, $c->getIterator() );
224
+		$this->assertEquals( ['foo'], $c->getIterator()->getArrayCopy() );
225 225
 	}
226 226
 
227 227
 	public function testFilter()
228 228
 	{
229
-		$c = new Map([['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']]);
230
-		$this->assertEquals([1 => ['id' => 2, 'name' => 'World']], $c->filter( function( $item ) {
229
+		$c = new Map( [['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']] );
230
+		$this->assertEquals( [1 => ['id' => 2, 'name' => 'World']], $c->filter( function( $item ) {
231 231
 			return $item['id'] == 2;
232
-		} )->toArray());
232
+		} )->toArray() );
233 233
 
234
-		$c = new Map(['', 'Hello', '', 'World']);
235
-		$this->assertEquals(['Hello', 'World'], $c->filter()->values()->toArray());
234
+		$c = new Map( ['', 'Hello', '', 'World'] );
235
+		$this->assertEquals( ['Hello', 'World'], $c->filter()->values()->toArray() );
236 236
 
237
-		$c = new Map(['id' => 1, 'first' => 'Hello', 'second' => 'World']);
238
-		$this->assertEquals(['first' => 'Hello', 'second' => 'World'], $c->filter( function( $item, $key ) {
237
+		$c = new Map( ['id' => 1, 'first' => 'Hello', 'second' => 'World'] );
238
+		$this->assertEquals( ['first' => 'Hello', 'second' => 'World'], $c->filter( function( $item, $key ) {
239 239
 			return $key != 'id';
240
-		} )->toArray());
240
+		} )->toArray() );
241 241
 	}
242 242
 
243 243
 	public function testValues()
244 244
 	{
245
-		$c = new Map([['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']]);
246
-		$this->assertEquals([['id' => 2, 'name' => 'World']], $c->filter( function( $item ) {
245
+		$c = new Map( [['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']] );
246
+		$this->assertEquals( [['id' => 2, 'name' => 'World']], $c->filter( function( $item ) {
247 247
 			return $item['id'] == 2;
248
-		} )->values()->toArray());
248
+		} )->values()->toArray() );
249 249
 	}
250 250
 
251 251
 	public function testMergeArray()
252 252
 	{
253
-		$c = new Map(['name' => 'Hello']);
254
-		$this->assertEquals(['name' => 'Hello', 'id' => 1], $c->merge(['id' => 1])->toArray());
253
+		$c = new Map( ['name' => 'Hello'] );
254
+		$this->assertEquals( ['name' => 'Hello', 'id' => 1], $c->merge( ['id' => 1] )->toArray() );
255 255
 	}
256 256
 
257 257
 	public function testMergeMap()
258 258
 	{
259
-		$c = new Map(['name' => 'Hello']);
260
-		$this->assertEquals(['name' => 'World', 'id' => 1], $c->merge(new Map(['name' => 'World', 'id' => 1]))->toArray());
259
+		$c = new Map( ['name' => 'Hello'] );
260
+		$this->assertEquals( ['name' => 'World', 'id' => 1], $c->merge( new Map( ['name' => 'World', 'id' => 1] ) )->toArray() );
261 261
 	}
262 262
 
263 263
 	public function testReplaceArray()
264 264
 	{
265
-		$c = new Map(['a', 'b', 'c']);
266
-		$this->assertEquals(['a', 'd', 'e'], $c->replace([1 => 'd', 2 => 'e'])->toArray());
265
+		$c = new Map( ['a', 'b', 'c'] );
266
+		$this->assertEquals( ['a', 'd', 'e'], $c->replace( [1 => 'd', 2 => 'e'] )->toArray() );
267 267
 	}
268 268
 
269 269
 	public function testReplaceMap()
270 270
 	{
271
-		$c = new Map(['a', 'b', 'c']);
271
+		$c = new Map( ['a', 'b', 'c'] );
272 272
 		$this->assertEquals(
273 273
 			['a', 'd', 'e'],
274
-			$c->replace(new Map([1 => 'd', 2 => 'e']))->toArray()
274
+			$c->replace( new Map( [1 => 'd', 2 => 'e'] ) )->toArray()
275 275
 		);
276 276
 	}
277 277
 
278 278
 	public function testReplaceRecursiveArray()
279 279
 	{
280
-		$c = new Map(['a', 'b', ['c', 'd']]);
281
-		$this->assertEquals(['z', 'b', ['c', 'e']], $c->replace(['z', 2 => [1 => 'e']])->toArray());
280
+		$c = new Map( ['a', 'b', ['c', 'd']] );
281
+		$this->assertEquals( ['z', 'b', ['c', 'e']], $c->replace( ['z', 2 => [1 => 'e']] )->toArray() );
282 282
 	}
283 283
 
284 284
 	public function testReplaceRecursiveMap()
285 285
 	{
286
-		$c = new Map(['a', 'b', ['c', 'd']]);
286
+		$c = new Map( ['a', 'b', ['c', 'd']] );
287 287
 		$this->assertEquals(
288 288
 			['z', 'b', ['c', 'e']],
289
-			$c->replace(new Map(['z', 2 => [1 => 'e']]))->toArray()
289
+			$c->replace( new Map( ['z', 2 => [1 => 'e']] ) )->toArray()
290 290
 		);
291 291
 	}
292 292
 
293 293
 	public function testUnionArray()
294 294
 	{
295
-		$c = new Map(['name' => 'Hello']);
296
-		$this->assertEquals(['name' => 'Hello', 'id' => 1], $c->union(['id' => 1])->toArray());
295
+		$c = new Map( ['name' => 'Hello'] );
296
+		$this->assertEquals( ['name' => 'Hello', 'id' => 1], $c->union( ['id' => 1] )->toArray() );
297 297
 	}
298 298
 
299 299
 	public function testUnionMap()
300 300
 	{
301
-		$c = new Map(['name' => 'Hello']);
302
-		$this->assertEquals(['name' => 'Hello', 'id' => 1], $c->union(new Map(['name' => 'World', 'id' => 1]))->toArray());
301
+		$c = new Map( ['name' => 'Hello'] );
302
+		$this->assertEquals( ['name' => 'Hello', 'id' => 1], $c->union( new Map( ['name' => 'World', 'id' => 1] ) )->toArray() );
303 303
 	}
304 304
 
305 305
 	public function testDiffMap()
306 306
 	{
307
-		$c = new Map(['id' => 1, 'first_word' => 'Hello']);
308
-		$this->assertEquals(['id' => 1], $c->diff(new Map(['first_word' => 'Hello', 'last_word' => 'World']))->toArray());
307
+		$c = new Map( ['id' => 1, 'first_word' => 'Hello'] );
308
+		$this->assertEquals( ['id' => 1], $c->diff( new Map( ['first_word' => 'Hello', 'last_word' => 'World'] ) )->toArray() );
309 309
 	}
310 310
 
311 311
 	public function testDiffUsingWithMap()
312 312
 	{
313
-		$c = new Map(['en_GB', 'fr', 'HR']);
313
+		$c = new Map( ['en_GB', 'fr', 'HR'] );
314 314
 		// demonstrate that diffKeys wont support case insensitivity
315
-		$this->assertEquals(['en_GB', 'fr', 'HR'], $c->diff(new Map(['en_gb', 'hr']))->values()->toArray());
315
+		$this->assertEquals( ['en_GB', 'fr', 'HR'], $c->diff( new Map( ['en_gb', 'hr'] ) )->values()->toArray() );
316 316
 	}
317 317
 
318 318
 	public function testDiffKeys()
319 319
 	{
320
-		$c1 = new Map(['id' => 1, 'first_word' => 'Hello']);
321
-		$c2 = new Map(['id' => 123, 'foo_bar' => 'Hello']);
322
-		$this->assertEquals(['first_word' => 'Hello'], $c1->diffKeys($c2)->toArray());
320
+		$c1 = new Map( ['id' => 1, 'first_word' => 'Hello'] );
321
+		$c2 = new Map( ['id' => 123, 'foo_bar' => 'Hello'] );
322
+		$this->assertEquals( ['first_word' => 'Hello'], $c1->diffKeys( $c2 )->toArray() );
323 323
 	}
324 324
 
325 325
 	public function testDiffKeysFunction()
326 326
 	{
327
-		$c1 = new Map(['id' => 1, 'first_word' => 'Hello']);
328
-		$c2 = new Map(['ID' => 123, 'foo_bar' => 'Hello']);
327
+		$c1 = new Map( ['id' => 1, 'first_word' => 'Hello'] );
328
+		$c2 = new Map( ['ID' => 123, 'foo_bar' => 'Hello'] );
329 329
 		// demonstrate that diffKeys wont support case insensitivity
330
-		$this->assertEquals(['id'=>1, 'first_word'=> 'Hello'], $c1->diffKeys($c2)->toArray());
330
+		$this->assertEquals( ['id'=>1, 'first_word'=> 'Hello'], $c1->diffKeys( $c2 )->toArray() );
331 331
 		// allow for case insensitive difference
332
-		$this->assertEquals(['first_word' => 'Hello'], $c1->diffKeys($c2, 'strcasecmp')->toArray());
332
+		$this->assertEquals( ['first_word' => 'Hello'], $c1->diffKeys( $c2, 'strcasecmp' )->toArray() );
333 333
 	}
334 334
 
335 335
 	public function testDiffAssoc()
336 336
 	{
337
-		$c1 = new Map(['id' => 1, 'first_word' => 'Hello', 'not_affected' => 'value']);
338
-		$c2 = new Map(['id' => 123, 'foo_bar' => 'Hello', 'not_affected' => 'value']);
339
-		$this->assertEquals(['id' => 1, 'first_word' => 'Hello'], $c1->diffAssoc($c2)->toArray());
337
+		$c1 = new Map( ['id' => 1, 'first_word' => 'Hello', 'not_affected' => 'value'] );
338
+		$c2 = new Map( ['id' => 123, 'foo_bar' => 'Hello', 'not_affected' => 'value'] );
339
+		$this->assertEquals( ['id' => 1, 'first_word' => 'Hello'], $c1->diffAssoc( $c2 )->toArray() );
340 340
 	}
341 341
 
342 342
 	public function testDiffAssocFunction()
343 343
 	{
344
-		$c1 = new Map(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red']);
345
-		$c2 = new Map(['A' => 'green', 'yellow', 'red']);
344
+		$c1 = new Map( ['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red'] );
345
+		$c2 = new Map( ['A' => 'green', 'yellow', 'red'] );
346 346
 		// demonstrate that the case of the keys will affect the output when diffAssoc is used
347
-		$this->assertEquals(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red'], $c1->diffAssoc($c2)->toArray());
347
+		$this->assertEquals( ['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red'], $c1->diffAssoc( $c2 )->toArray() );
348 348
 		// allow for case insensitive difference
349
-		$this->assertEquals(['b' => 'brown', 'c' => 'blue', 'red'], $c1->diffAssoc($c2, 'strcasecmp')->toArray());
349
+		$this->assertEquals( ['b' => 'brown', 'c' => 'blue', 'red'], $c1->diffAssoc( $c2, 'strcasecmp' )->toArray() );
350 350
 	}
351 351
 
352 352
 	public function testEach()
353 353
 	{
354
-		$c = new Map($original = [1, 2, 'foo' => 'bar', 'bam' => 'baz']);
354
+		$c = new Map( $original = [1, 2, 'foo' => 'bar', 'bam' => 'baz'] );
355 355
 
356 356
 		$result = [];
357 357
 		$c->each( function( $item, $key ) use ( &$result ) {
358 358
 			$result[$key] = $item;
359 359
 		} );
360
-		$this->assertEquals($original, $result);
360
+		$this->assertEquals( $original, $result );
361 361
 
362 362
 		$result = [];
363 363
 		$c->each( function( $item, $key ) use ( &$result ) {
@@ -366,196 +366,196 @@  discard block
 block discarded – undo
366 366
 				return false;
367 367
 			}
368 368
 		} );
369
-		$this->assertEquals([1, 2, 'foo' => 'bar'], $result);
369
+		$this->assertEquals( [1, 2, 'foo' => 'bar'], $result );
370 370
 	}
371 371
 
372 372
 	public function testIntersectMap()
373 373
 	{
374
-		$c = new Map(['id' => 1, 'first_word' => 'Hello']);
375
-		$this->assertEquals(['first_word' => 'Hello'], $c->intersect(new Map(['first_world' => 'Hello', 'last_word' => 'World']))->toArray());
374
+		$c = new Map( ['id' => 1, 'first_word' => 'Hello'] );
375
+		$this->assertEquals( ['first_word' => 'Hello'], $c->intersect( new Map( ['first_world' => 'Hello', 'last_word' => 'World'] ) )->toArray() );
376 376
 	}
377 377
 
378 378
 	public function testIntersectKeys()
379 379
 	{
380
-		$c = new Map(['name' => 'Mateus', 'age' => 18]);
381
-		$this->assertEquals(['name' => 'Mateus'], $c->intersectKeys(new Map(['name' => 'Mateus', 'surname' => 'Guimaraes']))->toArray());
380
+		$c = new Map( ['name' => 'Mateus', 'age' => 18] );
381
+		$this->assertEquals( ['name' => 'Mateus'], $c->intersectKeys( new Map( ['name' => 'Mateus', 'surname' => 'Guimaraes'] ) )->toArray() );
382 382
 	}
383 383
 
384 384
 	public function testUnique()
385 385
 	{
386
-		$c = new Map(['Hello', 'World', 'World']);
387
-		$this->assertEquals(['Hello', 'World'], $c->unique()->toArray());
386
+		$c = new Map( ['Hello', 'World', 'World'] );
387
+		$this->assertEquals( ['Hello', 'World'], $c->unique()->toArray() );
388 388
 	}
389 389
 
390 390
 	public function testSort()
391 391
 	{
392
-		$data = (new Map([5, 3, 1, 2, 4]))->sort();
393
-		$this->assertEquals([1, 2, 3, 4, 5], $data->values()->toArray());
392
+		$data = ( new Map( [5, 3, 1, 2, 4] ) )->sort();
393
+		$this->assertEquals( [1, 2, 3, 4, 5], $data->values()->toArray() );
394 394
 
395
-		$data = (new Map([-1, -3, -2, -4, -5, 0, 5, 3, 1, 2, 4]))->sort();
396
-		$this->assertEquals([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], $data->values()->toArray());
395
+		$data = ( new Map( [-1, -3, -2, -4, -5, 0, 5, 3, 1, 2, 4] ) )->sort();
396
+		$this->assertEquals( [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], $data->values()->toArray() );
397 397
 
398
-		$data = (new Map(['foo', 'bar-10', 'bar-1']))->sort();
399
-		$this->assertEquals(['bar-1', 'bar-10', 'foo'], $data->values()->toArray());
398
+		$data = ( new Map( ['foo', 'bar-10', 'bar-1'] ) )->sort();
399
+		$this->assertEquals( ['bar-1', 'bar-10', 'foo'], $data->values()->toArray() );
400 400
 	}
401 401
 
402 402
 	public function testKsort()
403 403
 	{
404
-		$data = new Map(['b' => 'me', 'a' => 'test']);
404
+		$data = new Map( ['b' => 'me', 'a' => 'test'] );
405 405
 
406
-		$this->assertSame(['a' => 'test', 'b' => 'me'], $data->ksort()->toArray());
406
+		$this->assertSame( ['a' => 'test', 'b' => 'me'], $data->ksort()->toArray() );
407 407
 	}
408 408
 
409 409
 	public function testReverse()
410 410
 	{
411
-		$data = new Map(['hello', 'world']);
411
+		$data = new Map( ['hello', 'world'] );
412 412
 		$reversed = $data->reverse();
413 413
 
414
-		$this->assertSame([1 => 'world', 0 => 'hello'], $reversed->toArray());
414
+		$this->assertSame( [1 => 'world', 0 => 'hello'], $reversed->toArray() );
415 415
 
416
-		$data = new Map(['name' => 'test', 'last' => 'user']);
416
+		$data = new Map( ['name' => 'test', 'last' => 'user'] );
417 417
 		$reversed = $data->reverse();
418 418
 
419
-		$this->assertSame(['last' => 'user', 'name' => 'test'], $reversed->toArray());
419
+		$this->assertSame( ['last' => 'user', 'name' => 'test'], $reversed->toArray() );
420 420
 	}
421 421
 
422 422
 	public function testHas()
423 423
 	{
424
-		$data = new Map(['id' => 1, 'first' => 'Hello', 'second' => 'World']);
425
-		$this->assertTrue($data->has('first'));
426
-		$this->assertFalse($data->has('third'));
424
+		$data = new Map( ['id' => 1, 'first' => 'Hello', 'second' => 'World'] );
425
+		$this->assertTrue( $data->has( 'first' ) );
426
+		$this->assertFalse( $data->has( 'third' ) );
427 427
 	}
428 428
 
429 429
 	public function testMethod()
430 430
 	{
431
-		Map::method('foo', function() {
431
+		Map::method( 'foo', function() {
432 432
 			return $this->filter( function( $item ) {
433
-				return strpos($item, 'a') === 0;
433
+				return strpos( $item, 'a' ) === 0;
434 434
 			})
435 435
 				->unique()
436 436
 				->values();
437 437
 		} );
438 438
 
439
-		$c = new Map(['a', 'a', 'aa', 'aaa', 'bar']);
439
+		$c = new Map( ['a', 'a', 'aa', 'aaa', 'bar'] );
440 440
 
441
-		$this->assertSame(['a', 'aa', 'aaa'], $c->foo()->toArray());
441
+		$this->assertSame( ['a', 'aa', 'aaa'], $c->foo()->toArray() );
442 442
 	}
443 443
 
444 444
 	public function testMakeMethodFromMap()
445 445
 	{
446
-		$firstMap = Map::from(['foo' => 'bar']);
447
-		$secondMap = Map::from($firstMap);
448
-		$this->assertEquals(['foo' => 'bar'], $secondMap->toArray());
446
+		$firstMap = Map::from( ['foo' => 'bar'] );
447
+		$secondMap = Map::from( $firstMap );
448
+		$this->assertEquals( ['foo' => 'bar'], $secondMap->toArray() );
449 449
 	}
450 450
 
451 451
 	public function testMakeMethodFromArray()
452 452
 	{
453
-		$map = Map::from(['foo' => 'bar']);
454
-		$this->assertEquals(['foo' => 'bar'], $map->toArray());
453
+		$map = Map::from( ['foo' => 'bar'] );
454
+		$this->assertEquals( ['foo' => 'bar'], $map->toArray() );
455 455
 	}
456 456
 
457 457
 	public function testConstructMethodFromMap()
458 458
 	{
459
-		$firstMap = new Map(['foo' => 'bar']);
460
-		$secondMap = new Map($firstMap);
461
-		$this->assertEquals(['foo' => 'bar'], $secondMap->toArray());
459
+		$firstMap = new Map( ['foo' => 'bar'] );
460
+		$secondMap = new Map( $firstMap );
461
+		$this->assertEquals( ['foo' => 'bar'], $secondMap->toArray() );
462 462
 	}
463 463
 
464 464
 	public function testConstructMethodFromArray()
465 465
 	{
466
-		$map = new Map(['foo' => 'bar']);
467
-		$this->assertEquals(['foo' => 'bar'], $map->toArray());
466
+		$map = new Map( ['foo' => 'bar'] );
467
+		$this->assertEquals( ['foo' => 'bar'], $map->toArray() );
468 468
 	}
469 469
 
470 470
 	public function testSplice()
471 471
 	{
472
-		$data = new Map(['foo', 'baz']);
473
-		$data->splice(1);
474
-		$this->assertEquals(['foo'], $data->toArray());
472
+		$data = new Map( ['foo', 'baz'] );
473
+		$data->splice( 1 );
474
+		$this->assertEquals( ['foo'], $data->toArray() );
475 475
 
476
-		$data = new Map(['foo', 'baz']);
477
-		$data->splice(1, 0, 'bar');
478
-		$this->assertEquals(['foo', 'bar', 'baz'], $data->toArray());
476
+		$data = new Map( ['foo', 'baz'] );
477
+		$data->splice( 1, 0, 'bar' );
478
+		$this->assertEquals( ['foo', 'bar', 'baz'], $data->toArray() );
479 479
 
480
-		$data = new Map(['foo', 'baz']);
481
-		$data->splice(1, 1);
482
-		$this->assertEquals(['foo'], $data->toArray());
480
+		$data = new Map( ['foo', 'baz'] );
481
+		$data->splice( 1, 1 );
482
+		$this->assertEquals( ['foo'], $data->toArray() );
483 483
 
484
-		$data = new Map(['foo', 'baz']);
485
-		$cut = $data->splice(1, 1, 'bar');
486
-		$this->assertEquals(['foo', 'bar'], $data->toArray());
487
-		$this->assertEquals(['baz'], $cut->toArray());
484
+		$data = new Map( ['foo', 'baz'] );
485
+		$cut = $data->splice( 1, 1, 'bar' );
486
+		$this->assertEquals( ['foo', 'bar'], $data->toArray() );
487
+		$this->assertEquals( ['baz'], $cut->toArray() );
488 488
 	}
489 489
 
490 490
 	public function testMap()
491 491
 	{
492
-		$data = new Map(['first' => 'test', 'last' => 'user']);
492
+		$data = new Map( ['first' => 'test', 'last' => 'user'] );
493 493
 		$data = $data->map( function( $item, $key ) {
494
-			return $key.'-'.strrev($item);
494
+			return $key . '-' . strrev( $item );
495 495
 		} );
496
-		$this->assertEquals(['first' => 'first-tset', 'last' => 'last-resu'], $data->toArray());
496
+		$this->assertEquals( ['first' => 'first-tset', 'last' => 'last-resu'], $data->toArray() );
497 497
 	}
498 498
 
499 499
 	public function testPullRetrievesItemFromMap()
500 500
 	{
501
-		$c = new Map(['foo', 'bar']);
501
+		$c = new Map( ['foo', 'bar'] );
502 502
 
503
-		$this->assertEquals('foo', $c->pull(0));
503
+		$this->assertEquals( 'foo', $c->pull( 0 ) );
504 504
 	}
505 505
 
506 506
 	public function testPullRemovesItemFromMap()
507 507
 	{
508
-		$c = new Map(['foo', 'bar']);
509
-		$c->pull(0);
510
-		$this->assertEquals([1 => 'bar'], $c->toArray());
508
+		$c = new Map( ['foo', 'bar'] );
509
+		$c->pull( 0 );
510
+		$this->assertEquals( [1 => 'bar'], $c->toArray() );
511 511
 	}
512 512
 
513 513
 	public function testPullReturnsDefault()
514 514
 	{
515
-		$c = new Map([]);
516
-		$value = $c->pull(0, 'foo');
517
-		$this->assertEquals('foo', $value);
515
+		$c = new Map( [] );
516
+		$value = $c->pull( 0, 'foo' );
517
+		$this->assertEquals( 'foo', $value );
518 518
 	}
519 519
 
520 520
 	public function testSearch()
521 521
 	{
522
-		$c = new Map([false, 0, 1, [], '']);
523
-		$this->assertNull($c->search('false'));
524
-		$this->assertNull($c->search('1'));
525
-		$this->assertEquals(0, $c->search(false));
526
-		$this->assertEquals(1, $c->search(0));
527
-		$this->assertEquals(2, $c->search(1));
528
-		$this->assertEquals(3, $c->search([]));
529
-		$this->assertEquals(4, $c->search(''));
522
+		$c = new Map( [false, 0, 1, [], ''] );
523
+		$this->assertNull( $c->search( 'false' ) );
524
+		$this->assertNull( $c->search( '1' ) );
525
+		$this->assertEquals( 0, $c->search( false ) );
526
+		$this->assertEquals( 1, $c->search( 0 ) );
527
+		$this->assertEquals( 2, $c->search( 1 ) );
528
+		$this->assertEquals( 3, $c->search( [] ) );
529
+		$this->assertEquals( 4, $c->search( '' ) );
530 530
 	}
531 531
 
532 532
 	public function testSearchReturnsNullWhenItemIsNotFound()
533 533
 	{
534
-		$c = new Map([1, 2, 3, 4, 5, 'foo' => 'bar']);
534
+		$c = new Map( [1, 2, 3, 4, 5, 'foo' => 'bar'] );
535 535
 
536
-		$this->assertNull($c->search(6));
537
-		$this->assertNull($c->search('foo'));
538
-		$this->assertNull($c->search( function( $value ) {
539
-			return $value < 1 && is_numeric($value);
540
-		} ));
541
-		$this->assertNull($c->search( function( $value ) {
536
+		$this->assertNull( $c->search( 6 ) );
537
+		$this->assertNull( $c->search( 'foo' ) );
538
+		$this->assertNull( $c->search( function( $value ) {
539
+			return $value < 1 && is_numeric( $value );
540
+		} ) );
541
+		$this->assertNull( $c->search( function( $value ) {
542 542
 			return $value == 'nope';
543
-		} ));
543
+		} ) );
544 544
 	}
545 545
 
546 546
 	public function testKeys()
547 547
 	{
548
-		$c = new Map(['name' => 'test', 'last' => 'user']);
549
-		$this->assertEquals(['name', 'last'], $c->keys()->toArray());
548
+		$c = new Map( ['name' => 'test', 'last' => 'user'] );
549
+		$this->assertEquals( ['name', 'last'], $c->keys()->toArray() );
550 550
 	}
551 551
 
552 552
 	public function testUnshift()
553 553
 	{
554
-		$c = new Map(['one', 'two', 'three', 'four']);
555
-		$this->assertEquals(['zero', 'one', 'two', 'three', 'four'], $c->unshift('zero')->toArray());
554
+		$c = new Map( ['one', 'two', 'three', 'four'] );
555
+		$this->assertEquals( ['zero', 'one', 'two', 'three', 'four'], $c->unshift( 'zero' )->toArray() );
556 556
 
557
-		$c = new Map(['one' => 1, 'two' => 2]);
558
-		$this->assertEquals(['zero' => 0, 'one' => 1, 'two' => 2], $c->unshift(0, 'zero')->toArray());
557
+		$c = new Map( ['one' => 1, 'two' => 2] );
558
+		$this->assertEquals( ['zero' => 0, 'one' => 1, 'two' => 2], $c->unshift( 0, 'zero' )->toArray() );
559 559
 	}
560 560
 
561 561
 	public function testConcatWithArray()
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
 			11 => 'Laroe',
576 576
 		];
577 577
 
578
-		$map = new Map([4, 5, 6]);
579
-		$map = $map->concat(['a', 'b', 'c']);
580
-		$map = $map->concat(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
581
-		$actual = $map->concat(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'])->toArray();
578
+		$map = new Map( [4, 5, 6] );
579
+		$map = $map->concat( ['a', 'b', 'c'] );
580
+		$map = $map->concat( ['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'] );
581
+		$actual = $map->concat( ['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'] )->toArray();
582 582
 
583
-		$this->assertSame($expected, $actual);
583
+		$this->assertSame( $expected, $actual );
584 584
 	}
585 585
 
586 586
 	public function testConcatWithMap()
@@ -600,27 +600,27 @@  discard block
 block discarded – undo
600 600
 			11 => 'Laroe',
601 601
 		];
602 602
 
603
-		$firstMap = new Map([4, 5, 6]);
604
-		$secondMap = new Map(['a', 'b', 'c']);
605
-		$thirdMap = new Map(['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe']);
606
-		$firstMap = $firstMap->concat($secondMap);
607
-		$firstMap = $firstMap->concat($thirdMap);
608
-		$actual = $firstMap->concat($thirdMap)->toArray();
603
+		$firstMap = new Map( [4, 5, 6] );
604
+		$secondMap = new Map( ['a', 'b', 'c'] );
605
+		$thirdMap = new Map( ['who' => 'Jonny', 'preposition' => 'from', 'where' => 'Laroe'] );
606
+		$firstMap = $firstMap->concat( $secondMap );
607
+		$firstMap = $firstMap->concat( $thirdMap );
608
+		$actual = $firstMap->concat( $thirdMap )->toArray();
609 609
 
610
-		$this->assertSame($expected, $actual);
610
+		$this->assertSame( $expected, $actual );
611 611
 	}
612 612
 
613 613
 	public function testReduce()
614 614
 	{
615
-		$data = new Map([1, 2, 3]);
616
-		$this->assertEquals(6, $data->reduce( function( $carry, $element ) {
615
+		$data = new Map( [1, 2, 3] );
616
+		$this->assertEquals( 6, $data->reduce( function( $carry, $element ) {
617 617
 			return $carry += $element;
618
-		} ));
618
+		} ) );
619 619
 	}
620 620
 
621 621
 	public function testPipe()
622 622
 	{
623
-		$map = new Map([1, 2, 3]);
623
+		$map = new Map( [1, 2, 3] );
624 624
 
625 625
 		$this->assertEquals( 3, $map->pipe( function( $map ) {
626 626
 			return $map->last();
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
 
630 630
 	public function testSliceOffset()
631 631
 	{
632
-		$map = new Map([1, 2, 3, 4, 5, 6, 7, 8]);
633
-		$this->assertEquals([4, 5, 6, 7, 8], $map->slice(3)->values()->toArray());
632
+		$map = new Map( [1, 2, 3, 4, 5, 6, 7, 8] );
633
+		$this->assertEquals( [4, 5, 6, 7, 8], $map->slice( 3 )->values()->toArray() );
634 634
 	}
635 635
 
636 636
 	public function testSliceNegativeOffset()
637 637
 	{
638
-		$map = new Map([1, 2, 3, 4, 5, 6, 7, 8]);
639
-		$this->assertEquals([6, 7, 8], $map->slice(-3)->values()->toArray());
638
+		$map = new Map( [1, 2, 3, 4, 5, 6, 7, 8] );
639
+		$this->assertEquals( [6, 7, 8], $map->slice(-3)->values()->toArray() );
640 640
 	}
641 641
 
642 642
 	public function testSliceOffsetAndLength()
643 643
 	{
644
-		$map = new Map([1, 2, 3, 4, 5, 6, 7, 8]);
645
-		$this->assertEquals([4, 5, 6], $map->slice(3, 3)->values()->toArray());
644
+		$map = new Map( [1, 2, 3, 4, 5, 6, 7, 8] );
645
+		$this->assertEquals( [4, 5, 6], $map->slice( 3, 3 )->values()->toArray() );
646 646
 	}
647 647
 
648 648
 	public function testSliceOffsetAndNegativeLength()
649 649
 	{
650
-		$map = new Map([1, 2, 3, 4, 5, 6, 7, 8]);
651
-		$this->assertEquals([4, 5, 6, 7], $map->slice(3, -1)->values()->toArray());
650
+		$map = new Map( [1, 2, 3, 4, 5, 6, 7, 8] );
651
+		$this->assertEquals( [4, 5, 6, 7], $map->slice( 3, -1 )->values()->toArray() );
652 652
 	}
653 653
 
654 654
 	public function testSliceNegativeOffsetAndLength()
655 655
 	{
656
-		$map = new Map([1, 2, 3, 4, 5, 6, 7, 8]);
657
-		$this->assertEquals([4, 5, 6], $map->slice(-5, 3)->values()->toArray());
656
+		$map = new Map( [1, 2, 3, 4, 5, 6, 7, 8] );
657
+		$this->assertEquals( [4, 5, 6], $map->slice(-5, 3)->values()->toArray() );
658 658
 	}
659 659
 
660 660
 	public function testSliceNegativeOffsetAndNegativeLength()
661 661
 	{
662
-		$map = new Map([1, 2, 3, 4, 5, 6, 7, 8]);
663
-		$this->assertEquals([3, 4, 5, 6], $map->slice(-6, -2)->values()->toArray());
662
+		$map = new Map( [1, 2, 3, 4, 5, 6, 7, 8] );
663
+		$this->assertEquals( [3, 4, 5, 6], $map->slice(-6, -2)->values()->toArray() );
664 664
 	}
665 665
 
666 666
 	public function testMapFromTraversable()
667 667
 	{
668
-		$map = new Map(new \ArrayObject([1, 2, 3]));
669
-		$this->assertEquals([1, 2, 3], $map->toArray());
668
+		$map = new Map( new \ArrayObject( [1, 2, 3] ) );
669
+		$this->assertEquals( [1, 2, 3], $map->toArray() );
670 670
 	}
671 671
 
672 672
 	public function testMapFromTraversableWithKeys()
673 673
 	{
674
-		$map = new Map(new \ArrayObject(['foo' => 1, 'bar' => 2, 'baz' => 3]));
675
-		$this->assertEquals(['foo' => 1, 'bar' => 2, 'baz' => 3], $map->toArray());
674
+		$map = new Map( new \ArrayObject( ['foo' => 1, 'bar' => 2, 'baz' => 3] ) );
675
+		$this->assertEquals( ['foo' => 1, 'bar' => 2, 'baz' => 3], $map->toArray() );
676 676
 	}
677 677
 
678 678
 	public function testHasReturnsValidResults()
679 679
 	{
680
-		$map = new Map(['foo' => 'one', 'bar' => 'two', 1 => 'three']);
681
-		$this->assertTrue($map->has('foo'));
680
+		$map = new Map( ['foo' => 'one', 'bar' => 'two', 1 => 'three'] );
681
+		$this->assertTrue( $map->has( 'foo' ) );
682 682
 	}
683 683
 
684 684
 	public function testSetAddsItemToMap()
685 685
 	{
686 686
 		$map = new Map;
687
-		$this->assertSame([], $map->toArray());
688
-		$map->set('foo', 1);
689
-		$this->assertSame(['foo' => 1], $map->toArray());
690
-		$map->set('bar', ['nested' => 'two']);
691
-		$this->assertSame(['foo' => 1, 'bar' => ['nested' => 'two']], $map->toArray());
692
-		$map->set('foo', 3);
693
-		$this->assertSame(['foo' => 3, 'bar' => ['nested' => 'two']], $map->toArray());
687
+		$this->assertSame( [], $map->toArray() );
688
+		$map->set( 'foo', 1 );
689
+		$this->assertSame( ['foo' => 1], $map->toArray() );
690
+		$map->set( 'bar', ['nested' => 'two'] );
691
+		$this->assertSame( ['foo' => 1, 'bar' => ['nested' => 'two']], $map->toArray() );
692
+		$map->set( 'foo', 3 );
693
+		$this->assertSame( ['foo' => 3, 'bar' => ['nested' => 'two']], $map->toArray() );
694 694
 	}
695 695
 
696 696
 	public function testGetWithNullReturnsNull()
697 697
 	{
698
-		$map = new Map([1, 2, 3]);
699
-		$this->assertNull($map->get(null));
698
+		$map = new Map( [1, 2, 3] );
699
+		$this->assertNull( $map->get( null ) );
700 700
 	}
701 701
 }
Please login to merge, or discard this patch.
lib/mwlib/src/MW/Map.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@
 block discarded – undo
34 34
 
35 35
 
36 36
    /**
37
-	 * Dynamically handle calls to the class.
38
-	 *
39
-	 * @param string $name Method name
40
-	 * @param array $params List of parameters
41
-	 * @return mixed Result from called function
42
-	 *
43
-	 * @throws \BadMethodCallException
44
-	 */
37
+    * Dynamically handle calls to the class.
38
+    *
39
+    * @param string $name Method name
40
+    * @param array $params List of parameters
41
+    * @return mixed Result from called function
42
+    *
43
+    * @throws \BadMethodCallException
44
+    */
45 45
 	public static function __callStatic( string $name, array $params )
46 46
 	{
47 47
 		if( !isset( static::$methods[$name] ) ) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -247,8 +247,7 @@  discard block
 block discarded – undo
247 247
 					return $value;
248 248
 				}
249 249
 			}
250
-		}
251
-		elseif( ( $result = reset( $this->items ) ) !== false )
250
+		} elseif( ( $result = reset( $this->items ) ) !== false )
252 251
 		{
253 252
 			return $result;
254 253
 		}
@@ -370,8 +369,7 @@  discard block
 block discarded – undo
370 369
 					return $value;
371 370
 				}
372 371
 			}
373
-		}
374
-		elseif( ( $result = end( $this->items ) ) !== false )
372
+		} elseif( ( $result = end( $this->items ) ) !== false )
375 373
 		{
376 374
 			return $result;
377 375
 		}
Please login to merge, or discard this patch.