SourcesResolver::resolvePackages()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 11
rs 10
c 0
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\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