Passed
Push — master ( b3a69d...79ebcc )
by Allan
02:21 queued 11s
created

ComposerConfigUtils::resolveConstraintPackages()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
nc 4
nop 1
dl 0
loc 22
rs 9.9
c 1
b 0
f 0
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Utils;
7
8
use Vaimo\ComposerPatches\Config;
9
10
class ComposerConfigUtils
11
{
12
    public function resolveConstraintPackages(\Composer\Config $composerConfig)
13
    {
14
        $platformOverrides = array_filter(
15
            (array)$composerConfig->get('platform')
16
        );
17
18
        if (!empty($platformOverrides)) {
19
            $platformOverrides = array();
20
        }
21
22
        $platformRepo = new \Composer\Repository\PlatformRepository(
23
            array(),
24
            $platformOverrides ?: array()
25
        );
26
27
        $platformPackages = array();
28
29
        foreach ($platformRepo->getPackages() as $package) {
30
            $platformPackages[$package->getName()] = $package;
31
        }
32
33
        return $platformPackages;
34
    }
35
}