MetricsCommand

Class
extends Command
Final: Yes
Attributes
#[AsCommand]
$name : 'reports:metrics'
$description : 'Analyzes code metrics with PhpMetrics.'
$aliases : ['reports:phpmetrics', 'phpmetrics', 'metrics']

Table of Contents

Constants

 = 'phpmetrics'
 = ['vendor', 'tmp', 'cache', 'spec', 'build', \FastForward\DevTools\Path\ManagedWorkspace::WORKSPACE_ROOT, 'backup', 'resources']
 = \E_ALL & ~\E_DEPRECATED

Properties

Methods

 : mixed
addJsonOption()

Adds the standard JSON output options to the current command.

 : static
 : void
 : int
isJsonOutput()

Determines whether JSON output was requested.

 : bool
isPrettyJsonOutput()

Determines whether pretty JSON output was requested.

 : bool
failure()

Logs a failed command result and returns the failure exit code.

 : int
getDefaultExcludedDirectories()

Returns the default PhpMetrics directory exclusion list.

 : array<int, string>
isImplicitJsonOutputEnabled()

Determines whether structured JSON output SHOULD be enabled implicitly.

 : bool
isOptionEnabled()

Determines whether a boolean input option was enabled.

 : bool
log()

Logs a non-terminal command message unless structured JSON output is active.

 : void
success()

Logs a successful command result and returns the success exit code.

 : int
Constants

Constants

BINARY

Private
private string BINARY = 'phpmetrics'

Description

the PhpMetrics binary name resolved through the runtime-aware tooling lookup

DEFAULT_EXCLUDED_DIRECTORIES

Private
private array<int, string> DEFAULT_EXCLUDED_DIRECTORIES = ['vendor', 'tmp', 'cache', 'spec', 'build', \FastForward\DevTools\Path\ManagedWorkspace::WORKSPACE_ROOT, 'backup', 'resources']

Description

the directories PhpMetrics SHOULD skip by default

PHP_DEFAULT_SOCKET_TIMEOUT

Private
private int PHP_DEFAULT_SOCKET_TIMEOUT = 1

Description

the maximum seconds PhpMetrics may wait on each Packagist package lookup

PHP_ERROR_REPORTING

Private
private int PHP_ERROR_REPORTING = \E_ALL & ~\E_DEPRECATED

Description

the PHP error reporting mask that suppresses deprecations emitted by PhpMetrics internals

Properties
Methods

addJsonOption()

Protected

Adds the standard JSON output options to the current command.

protected addJsonOption() : static
Return values
static

execute()

Protected
protected execute(InputInterface  $input, OutputInterface  $output) : int
Parameters
$input : InputInterface

Description

the runtime command input

$output : OutputInterface

Description

the console output stream

Return values
int

Description

the command execution status code

isJsonOutput()

Protected

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
bool

isPrettyJsonOutput()

Protected

Determines whether pretty JSON output was requested.

protected isPrettyJsonOutput(InputInterface  $input) : bool
Parameters
$input : InputInterface
Return values
bool

failure()

Private

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
int

getDefaultExcludedDirectories()

Private

Returns the default PhpMetrics directory exclusion list.

private getDefaultExcludedDirectories() : array<int, string>
Return values
array<int, string>

isImplicitJsonOutputEnabled()

Private

Determines whether structured JSON output SHOULD be enabled implicitly.

private isImplicitJsonOutputEnabled() : bool

Description

Commands MAY opt into runtime-environment-aware behavior by exposing a $runtimeEnvironment property. Commands that do not expose it SHALL fall back to the shared runtime-environment service from the DevTools container.

Return values
bool

isOptionEnabled()

Private

Determines whether a boolean input option was enabled.

private isOptionEnabled(InputInterface  $input, string  $option) : bool
Parameters
$input : InputInterface
$option : string
Return values
bool

log()

Private

Logs a non-terminal command message unless structured JSON output is active.

private log( string  $message, InputInterface  $input[, array<string, mixed>  $context = []][, string  $logLevel = LogLevel::INFO]) : void
Parameters
$message : string

Description

the progress 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 message

success()

Private

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

Return values
int