ComposerOperationAnalyser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isPluginUninstallOperation() 0 10 3
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 Composer\DependencyResolver\Operation\OperationInterface;
9
10
class ComposerOperationAnalyser
11
{
12
    /**
13
     * @var \Vaimo\ComposerChangelogs\Analysers\PackageAnalyser
14
     */
15
    private $packageAnalyser;
16
    
17
    public function __construct()
18
    {
19
        $this->packageAnalyser = new \Vaimo\ComposerChangelogs\Analysers\PackageAnalyser();
20
    }
21
22
    public function isPluginUninstallOperation(OperationInterface $operation)
23
    {
24
        if (!$operation instanceof \Composer\DependencyResolver\Operation\UninstallOperation) {
25
            return false;
26
        }
27
28
        $package = $operation->getPackage();
29
30
        return $this->packageAnalyser->isPluginPackage($package)
31
            && $this->packageAnalyser->ownsNamespace($package, __NAMESPACE__);
32
    }
33
}
34