ConfigAnalyser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isPluginPackage() 0 3 1
A __construct() 0 3 1
A ownsNamespace() 0 6 2
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Package;
7
8
class ConfigAnalyser
9
{
10
    /**
11
     * @var \Vaimo\ComposerPatches\Package\ConfigExtractors\NamespaceConfigExtractor
12
     */
13
    private $namespacesExtractor;
14
15
    public function __construct()
16
    {
17
        $this->namespacesExtractor = new \Vaimo\ComposerPatches\Package\ConfigExtractors\NamespaceConfigExtractor();
18
    }
19
20
    public function isPluginPackage(\Composer\Package\PackageInterface $package)
21
    {
22
        return $package->getType() === \Vaimo\ComposerPatches\Composer\ConfigKeys::COMPOSER_PLUGIN_TYPE;
23
    }
24
25
    public function ownsNamespace(\Composer\Package\PackageInterface $package, $namespace)
26
    {
27
        return (bool)array_filter(
28
            $this->namespacesExtractor->getConfig($package, ''),
29
            function ($item) use ($namespace) {
30
                return $item && strpos($namespace, rtrim($item, '\\')) === 0;
31
            }
32
        );
33
    }
34
}
35