RepositoryUtils::filterByDependency()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
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 Composer\Repository\WritableRepositoryInterface;
9
10
class RepositoryUtils
11
{
12
    /**
13
     * @var \Vaimo\ComposerPatches\Compatibility\DependenciesFactory
14
     */
15
    private $composerDependencies;
16
17
    public function __construct()
18
    {
19
        $this->composerDependencies = new \Vaimo\ComposerPatches\Compatibility\DependenciesFactory();
20
    }
21
22
    public function filterByDependency(WritableRepositoryInterface $repository, $dependencyName)
23
    {
24
        $depsRepository = $this->composerDependencies->createCompositeRepository($repository);
25
        $dependents = $depsRepository->getDependents($dependencyName);
0 ignored issues
show
introduced by
The method getDependents() does not exist on Composer\Repository\CompositeRepository. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        /** @scrutinizer ignore-call */ 
26
        $dependents = $depsRepository->getDependents($dependencyName);
Loading history...
26
        $dependentsList = array_column($dependents, 0);
27
28
        return array_filter($dependentsList);
29
    }
30
}
31