Conditions | 2 |
Paths | 2 |
Total Lines | 32 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 2.0006 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | 2 | public function exportToArray(): array |
|
10 | { |
||
11 | 2 | $data = $this->getEvent()->getComposer()->getLocker()->getLockData(); |
|
12 | |||
13 | 2 | $packagesData = array_merge( |
|
14 | 2 | $data['packages'], |
|
15 | 2 | $data['packages-dev'] |
|
16 | ); |
||
17 | |||
18 | 2 | $packageNames = array_map( |
|
19 | static function (array $data): string { |
||
20 | 2 | return $data['name']; |
|
21 | 2 | }, |
|
22 | 2 | $packagesData |
|
23 | ); |
||
24 | |||
25 | 2 | $packageVersions = array_map( |
|
26 | static function (array $data): string { |
||
27 | 2 | return $data['version']; |
|
28 | 2 | }, |
|
29 | 2 | $packagesData |
|
30 | ); |
||
31 | |||
32 | 2 | if (false === $versions = array_combine($packageNames, $packageVersions)) { |
|
33 | 2 | return []; |
|
34 | } |
||
35 | 2 | ||
36 | ksort($versions); |
||
37 | 2 | ||
38 | return [ |
||
|
|||
39 | 'package_names' => $packageNames, |
||
40 | 'regex' => $this->buildRegex($versions), |
||
41 | ]; |
||
61 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: