PackageAnalyser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 23
rs 10

3 Methods

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