-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDetailedVersionedPackage.php
More file actions
126 lines (112 loc) · 3.41 KB
/
DetailedVersionedPackage.php
File metadata and controls
126 lines (112 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
namespace Winter\Packager\Package;
use Composer\Package\Version\VersionParser;
use Winter\Packager\Enums\VersionStatus;
/**
* @author Ben Thomson <git@alfreido.com>
* @since 0.3.0
*/
class DetailedVersionedPackage extends DetailedPackage
{
protected string $versionNormalized;
protected string $latestVersionNormalized;
/**
* Constructor.
*
* @param array<int, string> $keywords
* @param array<int, array<string, string>> $authors
* @param array<int, array<string, string>> $licenses
* @param array<string, string> $support
* @param array<string, string> $funding
* @param array<string, string> $requires
* @param array<string, string> $devRequires
* @param array<string, mixed> $extras
* @param array<string, string> $suggests
* @param array<string, string> $conflicts
* @param array<string, string> $replaces
*/
public function __construct(
string $namespace,
string $name,
string $description = '',
protected string $type = 'library',
protected ?string $path = null,
protected array $keywords = [],
protected string $homepage = '',
protected array $authors = [],
protected array $licenses = [],
protected array $support = [],
protected array $funding = [],
protected array $requires = [],
protected array $devRequires = [],
protected array $extras = [],
protected array $suggests = [],
protected array $conflicts = [],
protected array $replaces = [],
protected string $readme = '',
protected string $version = '',
protected string $latestVersion = '',
protected VersionStatus $updateStatus = VersionStatus::UP_TO_DATE,
) {
parent::__construct(
$namespace,
$name,
$description,
$type,
$path,
$keywords,
$homepage,
$authors,
$licenses,
$support,
$funding,
$requires,
$devRequires,
$extras,
$suggests,
$conflicts,
$replaces,
$readme,
);
$this->versionNormalized = $this->normalizeVersion($version);
}
public function setVersion(string $version): void
{
$this->version = $version;
$this->versionNormalized = $this->normalizeVersion($version);
}
public function getVersion(): string
{
return $this->version;
}
public function getVersionNormalized(): string
{
return $this->versionNormalized;
}
public function setLatestVersion(string $latestVersion): void
{
$this->latestVersion = $latestVersion;
$this->latestVersionNormalized = $this->normalizeVersion($latestVersion);
}
public function getLatestVersion(): string
{
return $this->latestVersion;
}
public function getLatestVersionNormalized(): string
{
return $this->latestVersionNormalized;
}
public function setUpdateStatus(VersionStatus $updateStatus): void
{
$this->updateStatus = $updateStatus;
}
public function getUpdateStatus(): VersionStatus
{
return $this->updateStatus;
}
protected function normalizeVersion(string $version): string
{
$parser = new VersionParser;
return $parser->normalize($version);
}
}