Passed
Push — master ( d8dbec...ed6753 )
by Dominik
02:49
created

Dependency::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dominikb\ComposerLicenseChecker;
6
7
class Dependency
8
{
9
    /** @var string */
10
    private $name;
11
12
    /** @var string */
13
    private $version;
14
15
    /** @var string[] */
16
    private $licenses;
17
18
    /**
19
     * Dependency constructor.
20
     *
21
     * @param string   $name
22
     * @param string   $version
23
     * @param string[] $licenses
24
     */
25 15
    public function __construct(string $name = '', string $version = '', array $licenses = [])
26
    {
27 15
        $this->name = $name;
28 15
        $this->version = $version;
29 15
        $this->licenses = $licenses;
30 15
    }
31
32
    /**
33
     * @return string
34
     */
35 7
    public function getName(): string
36
    {
37 7
        return $this->name;
38
    }
39
40
    /**
41
     * @param string $name
42
     */
43 8
    public function setName(string $name): self
44
    {
45 8
        $this->name = $name;
46
47 8
        return $this;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 7
    public function getVersion(): string
54
    {
55 7
        return $this->version;
56
    }
57
58
    /**
59
     * @param string $version
60
     */
61 8
    public function setVersion(string $version): self
62
    {
63 8
        $this->version = $version;
64
65 8
        return $this;
66
    }
67
68
    /**
69
     * @return string[]
70
     */
71 11
    public function getLicenses(): array
72
    {
73 11
        return $this->licenses;
74
    }
75
76
    /**
77
     * @param string[] $licenses
78
     */
79 12
    public function setLicenses(array $licenses): self
80
    {
81 12
        $this->licenses = $licenses;
82
83 12
        return $this;
84
    }
85
86 2
    public function getAuthorName(): string
87
    {
88 2
        return explode('/', $this->name)[0];
89
    }
90
91 2
    public function getPackageName(): string
92
    {
93 2
        $parts = explode('/', $this->name);
94
95 2
        if (count($parts) != 2) {
96 1
            return '';
97
        }
98
99 1
        return $parts[1];
100
    }
101
}
102