File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -17,19 +17,19 @@ public function get(string $phpVersion = null): array
17
17
try {
18
18
$ contents = $ this ->fetch ();
19
19
20
- return $ this ->cache = str ($ contents )
21
- ->explode ("\n" )
20
+ return $ this ->cache = collect ($ contents )
22
21
->filter (fn (string $ extension ): bool => is_null ($ phpVersion ) || str ($ extension )->contains ($ phpVersion ))
23
22
->map (fn (string $ extension ): string => str ($ extension )->trim ()->before (' ' ))
24
23
->filter ()
24
+ ->values ()
25
25
->toArray ();
26
26
} catch (\ErrorException ) {
27
27
return [];
28
28
}
29
29
}
30
30
31
- protected function fetch (): string |false
31
+ protected function fetch (): array |false
32
32
{
33
- return file_get_contents (self ::URL );
33
+ return file (self ::URL );
34
34
}
35
35
}
Original file line number Diff line number Diff line change @@ -24,13 +24,13 @@ protected function setUp(): void
24
24
->passthru ();
25
25
$ mock ->shouldReceive ('fetch ' )
26
26
->once ()
27
- ->andReturn (<<<'RES'
28
- apcu 8.1 8.2
29
- pdo_mysql 8.2
30
- pdo_pgsql 8.0 8.1
31
- memcached 8.0
32
- redis 8.1
33
- RES );
27
+ ->andReturn ([
28
+ ' apcu 8.1 8.2 ' ,
29
+ ' pdo_mysql 8.2 ' ,
30
+ ' pdo_pgsql 8.0 8.1 ' ,
31
+ ' memcached 8.0 ' ,
32
+ ' redis 8.1 ' ,
33
+ ] );
34
34
});
35
35
}
36
36
@@ -44,10 +44,10 @@ public function providePhpVersions(): array
44
44
}
45
45
46
46
/** @dataProvider providePhpVersions */
47
- public function testItFiltersVersions (): void
47
+ public function testItFiltersVersions ($ expected , $ version ): void
48
48
{
49
- $ supported = app (SupportedPhpExtensions::class)->get (' 8.2 ' );
49
+ $ supported = app (SupportedPhpExtensions::class)->get ($ version );
50
50
51
- self ::assertEquals ([ ' apcu ' , ' pdo_mysql ' ] , $ supported );
51
+ self ::assertEquals ($ expected , $ supported );
52
52
}
53
53
}
You can’t perform that action at this time.
0 commit comments