RepositoryUtils   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A filterByDependency() 0 7 1
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