GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

UninstallHandler::getOutput()   B
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 18
cts 18
cp 1
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 16
nc 2
nop 2
crap 3
1
<?php
2
3
/*
4
 * This file is part of the composer-changelogs project.
5
 *
6
 * (c) Loïck Piera <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Pyrech\ComposerChangelogs\OperationHandler;
13
14
use Composer\DependencyResolver\Operation\OperationInterface;
15
use Composer\DependencyResolver\Operation\UninstallOperation;
16
use Composer\Package\Version\VersionParser;
17
use Pyrech\ComposerChangelogs\UrlGenerator\UrlGenerator;
18
use Pyrech\ComposerChangelogs\Version;
19
20
class UninstallHandler implements OperationHandler
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 4
    public function supports(OperationInterface $operation)
26
    {
27 4
        return $operation instanceof UninstallOperation;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 4
    public function extractSourceUrl(OperationInterface $operation)
34
    {
35 4
        if (!($operation instanceof UninstallOperation)) {
36 2
            throw new \LogicException('Operation should be an instance of UninstallOperation');
37
        }
38
39 2
        return $operation->getPackage()->getSourceUrl();
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 10
    public function getOutput(OperationInterface $operation, UrlGenerator $urlGenerator = null)
46
    {
47 10
        if (!($operation instanceof UninstallOperation)) {
48 2
            throw new \LogicException('Operation should be an instance of UninstallOperation');
49
        }
50
51 8
        $output = [];
52
53 8
        $package = $operation->getPackage();
54 8
        $version = new Version(
55 8
            $package->getVersion(),
56 8
            $package->getPrettyVersion(),
57 8
            method_exists($package, 'getFullPrettyVersion') // This method was added after composer v1.0.0-alpha10
58 8
                ? $package->getFullPrettyVersion()
59 8
                : VersionParser::formatVersion($package)
60 8
        );
61
62 8
        $output[] = sprintf(
63 8
            ' - <fg=green>%s</fg=green> removed (installed version was <fg=yellow>%s</fg=yellow>)',
64 8
            $package->getName(),
65 8
            $version->getPretty()
66 8
        );
67
68 8
        return $output;
69
    }
70
}
71