ConfigAnalyser::isPluginPackage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
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\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