Passed
Push — master ( e2b3f8...ef86f2 )
by Pol
04:04
created

Versions::exportToArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 26
ccs 15
cts 15
cp 1
crap 1
rs 9.7998
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\ComposerPackages\Exporter;
6
7
class Versions extends Exporter
8
{
9
    /**
10
     * @return array
11
     */
12 2
    public function exportToArray(): array
13
    {
14 2
        $data = $this->getEvent()->getComposer()->getLocker()->getLockData();
15
16 2
        $packagesData = \array_merge(
17 2
            $data['packages'],
18 2
            $data['packages-dev']
19
        );
20
21 2
        $packageNames = \array_map(
22
            static function (array $data) {
23 2
                return $data['name'];
24 2
            },
25 2
            $packagesData
26
        );
27
28 2
        $packageVersions = \array_map(
29
            static function (array $data) {
30 2
                return $data['version'];
31 2
            },
32 2
            $packagesData
33
        );
34
35 2
        $versions = \array_combine($packageNames, $packageVersions);
36
37 2
        return \compact('versions');
38
    }
39
}
40