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

ComposerConfigUtils   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveConstraintPackages() 0 22 4
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
}