Resolves license identifiers to their corresponding template filenames.
Description
This class maintains a mapping of supported open-source licenses to their template files and provides methods to check support and resolve licenses.
Interfaces
Constants
Methods
Checks whether the given license identifier is supported.
Resolves a license identifier to its template filename.
Normalizes the license identifier for comparison.
private
mixed
SUPPORTED_LICENSES
=
['MIT' => 'mit.txt', 'BSD-2-Clause' => 'bsd-2-clause.txt', 'BSD-3-Clause' => 'bsd-3-clause.txt', 'Apache-2.0' => 'apache-2.0.txt', 'Apache-2' => 'apache-2.0.txt', 'GPL-3.0-or-later' => 'gpl-3.0-or-later.txt', 'GPL-3.0' => 'gpl-3.0-or-later.txt', 'GPL-3+' => 'gpl-3.0-or-later.txt', 'LGPL-3.0-or-later' => 'lgpl-3.0-or-later.txt', 'LGPL-3.0' => 'lgpl-3.0-or-later.txt', 'LGPL-3+' => 'lgpl-3.0-or-later.txt', 'MPL-2.0' => 'mpl-2.0.txt', 'ISC' => 'isc.txt', 'Unlicense' => 'unlicense.txt']
Checks whether the given license identifier is supported.
public
isSupported(
string
$license) : bool
Description
The check is case-insensitive and handles common license variants.
Parameters
$license
:
string
Description
The license identifier to check
Return values
Description
True if the license is supported, false otherwise
Resolves a license identifier to its template filename.
public
resolve(
string
$license) : string|null
Parameters
$license
:
string
Description
The license identifier to resolve
Return values
Description
The template filename if supported, or null if not
Normalizes the license identifier for comparison.
private
normalize(
string
$license) : string
Parameters
$license
:
string
Description
The license identifier to normalize
Return values
Description
The normalized license string