File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff line change 44
55final 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}
You can’t perform that action at this time.
0 commit comments