Generates and copies LICENSE files to projects.
Description
This command generates a LICENSE file if one does not exist and a supported license is declared in composer.json.
'license'
'Generates a LICENSE file from composer.json license information.'
'This command generates a LICENSE file if one does not exist and a supported license is declared in composer.json.'
Interfaces
Defines the logger contract consumed by reusable command result helpers.
Properties
Methods
Creates a new LicenseCommand instance.
Adds the standard JSON output options to the current command.
{@inheritDoc}
Executes the license generation process.
Determines whether JSON output was requested.
Determines whether pretty JSON output was requested.
Logs a failed command result and returns the failure exit code.
Logs an informational command message at notice level.
Prompts whether the generated LICENSE should be written.
Logs a successful command result and returns the success exit code.
private
FileDiffer
$fileDiffer
private
FilesystemInterface
$filesystem
private
GeneratorInterface
$generator
private
LoggerInterface
$logger
Creates a new LicenseCommand instance.
public
__construct(GeneratorInterface
$generator, FilesystemInterface
$filesystem, FileDiffer
$fileDiffer, LoggerInterface
$logger) : mixed
Parameters
Description
the generator component
Description
the filesystem component
$logger
:
LoggerInterface
Description
the output-aware logger
Adds the standard JSON output options to the current command.
protected
addJsonOption() : static
Return values
{@inheritDoc}
protected
configure() : void
Executes the license generation process.
protected
execute(InputInterface
$input, OutputInterface
$output) : int
Description
Generates a LICENSE file if one does not exist and a supported license is declared in composer.json.
Parameters
$input
:
InputInterface
Description
the input interface
$output
:
OutputInterface
Description
the output interface
Return values
Description
the status code
Determines whether JSON output was requested.
protected
isJsonOutput(InputInterface
$input) : bool
Description
The pretty-json flag SHALL imply JSON output.
Parameters
$input
:
InputInterface
Return values
Determines whether pretty JSON output was requested.
protected
isPrettyJsonOutput(InputInterface
$input) : bool
Parameters
$input
:
InputInterface
Return values
Logs a failed command result and returns the failure exit code.
private
failure(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string|null
$file = null][,
int|null
$line = null]) : int
Parameters
$message
:
string
Description
the failure message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$file
:
string|null
=
null
Description
the related file path when known
$line
:
int|null
=
null
Description
the related line when known
Return values
Logs an informational command message at notice level.
private
notice(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []]) : void
Parameters
$message
:
string
Description
the notice message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
Prompts whether the generated LICENSE should be written.
private
shouldWriteLicense(
string
$targetPath) : bool
Parameters
$targetPath
:
string
Description
the license path that would be written
Return values
Description
true when the write SHOULD proceed
Logs a successful command result and returns the success exit code.
private
success(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string
$logLevel = LogLevel::INFO]) : int
Parameters
$message
:
string
Description
the success message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$logLevel
:
string
=
LogLevel::INFO
Description
the PSR-3 log level used for the successful result