Skip to content

Commit c6b9232

Browse files
committed
Generate License URL as well
So, we can mention it in the README for better convenience
1 parent b27c34c commit c6b9232

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

src/Command/Markdown/Builder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(array $data)
2626
$this->authorName = $data['author'];
2727
$this->authorEmail = $data['email'];
2828
$this->licenseType = $data['license'];
29+
$this->licenseLink = License::getLicenseLink($data['license']);
2930
}
3031

3132
public function save(string $path): bool|int
@@ -56,7 +57,8 @@ private function parse(string $contents): string
5657
$this->description,
5758
$this->authorName,
5859
$this->authorEmail,
59-
$this->licenseType
60+
$this->licenseType,
61+
$this->licenseLink,
6062
],
6163
$contents
6264
);

src/Command/Markdown/License.php

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,42 @@
44

55
final class License
66
{
7+
private const ISC = 'ISC';
8+
private const MIT = 'MIT';
9+
private const GPL = 'GPL';
10+
private const BSD = 'BSD';
11+
private const MPL = 'MPL';
12+
private const AGPL = 'AGPL'
13+
714
public const CODES = [
8-
'ISC',
9-
'MIT',
10-
'GPL',
11-
'BSD'
15+
self::ISC,
16+
self::MIT,
17+
self::GPL,
18+
self::BSD,
19+
self::MPL,
20+
self::AGPL,
1221
];
22+
23+
public static function getLicenseLink($licenseType)
24+
{
25+
switch ($licenseType) {
26+
case self::ISC:
27+
return 'https://opensource.org/licenses/ISC';
28+
29+
case self::MIT:
30+
return 'https://opensource.org/licenses/MIT';
31+
32+
case self::GPL:
33+
return 'https://www.gnu.org/licenses/gpl.html';
34+
35+
case self::MPL:
36+
return 'https://www.mozilla.org/en-US/MPL/';
37+
38+
case self::AGPL:
39+
return 'https://www.gnu.org/licenses/agpl.html';
40+
41+
default:
42+
return 'https://opensource.org/licenses/';
43+
}
44+
}
1345
}

0 commit comments

Comments
 (0)