Package   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 43
ccs 0
cts 0
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A isInstalled() 0 8 2
1
<?php
2
namespace PackageInfo;
3
4
use PackageInfo\Exception\PackageNotInstalledException;
5
6
/**
7
 * This class is generated by thadafinser/package-info
8
 *
9
 * This file is overwritten at every run of `composer install` or `composer update`.
10
 */
11
final class Package
12
{
13
    const PACKAGES = [];
14
15
    /**
16
     * 
17
     * @var string
18
     */
19
    private $name;
20
    
21
    /**
22
     * 
23
     * @param string $name
24
     * @throws PackageNotInstalledException
25
     */
26
    public function __construct($name)
27
    {
28
        $this->name = $name;
29
        
30
        if (! $this->isInstalled($name)) {
31
            throw new PackageNotInstalledException('Package "'.$name.'" is not installed through composer, or you installed it with the flag --no-scripts');
32
        }
33
    }
34
    
35
    /**
36
     * Check if the given package is installed
37
     * 
38
     * @return boolean
39
     */
40
    public static function isInstalled($name)
41
    {
42
        if (array_key_exists($name, self::PACKAGES)) {
43
            return true;
44
        }
45
        
46
        return false;
47
    }
48
    
49
    /**
50
     * NOTE: i removed per default all other methods.
51
     * They are not static and on Package::__construct() the exception will be thrown
52
     */
53
}
54