SourcesResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolvePackages() 0 11 1
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Patch;
7
8
use Composer\Repository\WritableRepositoryInterface as PackageRepository;
9
10
use Vaimo\ComposerPatches\Interfaces\PatchSourceListInterface;
11
12
class SourcesResolver
13
{
14
    /**
15
     * @var PatchSourceListInterface[]
16
     */
17
    private $listSources;
18
19
    /**
20
     * @param PatchSourceListInterface[] $listSources
21
     */
22
    public function __construct(
23
        array $listSources
24
    ) {
25
        $this->listSources = $listSources;
26
    }
27
28
    public function resolvePackages(PackageRepository $repository)
29
    {
30
        $result = array_reduce(
31
            $this->listSources,
32
            function ($result, PatchSourceListInterface $listSource) use ($repository) {
33
                return array_merge($result, $listSource->getItems($repository));
34
            },
35
            array()
36
        );
37
38
        return array_unique($result);
39
    }
40
}
41