Completed
Push — master ( da1a6c...6bb072 )
by Marco
02:08
created

UnknownPackageFormat   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromNonGitPackage() 0 4 1
A packageName() 0 4 1
A isVerified() 0 4 1
A printReason() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\ComposerGpgVerify\Package;
6
7
use Composer\Package\PackageInterface;
8
9
/**
10
 * @internal do not use: I will cut you.
11
 *
12
 * This class represents a package verification for an unknown package type.
13
 * Currently, this repository only knows how to verify GPG+GIT, so anything ZIP/HG/CVS/etc will be considered "unknown"
14
 */
15
final class UnknownPackageFormat implements PackageVerification
16
{
17
    /**
18
     * @var string
19
     */
20
    private $packageName;
21
22
    private function __construct(string $packageName)
23
    {
24
        $this->packageName = $packageName;
25
    }
26
27
    public static function fromNonGitPackage(PackageInterface $package) : self
28
    {
29
        return new self($package->getName());
30
    }
31
32
    public function packageName(): string
33
    {
34
        return $this->packageName;
35
    }
36
37
    public function isVerified(): bool
38
    {
39
        return false;
40
    }
41
42
    public function printReason(): string
43
    {
44
        return sprintf(
45
            'Package "%s" is in a format that Roave\\ComposerGpgVerify cannot verify:'
46
            . ' try forcing it to be downloaded as GIT repository',
47
            $this->packageName()
48
        );
49
    }
50
}
51