PackageAnalyser::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerChangelogs\Analysers;
7
8
use Vaimo\ComposerChangelogs\Composer\Config as ComposerConfig;
9
10
class PackageAnalyser
11
{
12
    /**
13
     * @var \Vaimo\ComposerChangelogs\Extractors\NamespacesExtractor
14
     */
15
    private $namespacesExtractor;
16
    
17
    public function __construct()
18
    {
19
        $this->namespacesExtractor = new \Vaimo\ComposerChangelogs\Extractors\NamespacesExtractor();
20
    }
21
22
    public function isPluginPackage(\Composer\Package\PackageInterface $package)
23
    {
24
        return $package->getType() === ComposerConfig::COMPOSER_PLUGIN_TYPE;
25
    }
26
    
27
    public function ownsNamespace(\Composer\Package\PackageInterface $package, $namespace)
28
    {
29
        return (bool)array_filter(
30
            $this->namespacesExtractor->getConfig($package),
31
            function ($item) use ($namespace) {
32
                return strpos($namespace, rtrim($item, '\\')) === 0;
33
            }
34
        );
35
    }
36
}
37