HasCacheOption

Trait

Provides the standard cache option used by cache-writing commands.

Table of Contents

Methods

addCacheDirOption()

Adds the standard cache directory option to the current command.

 : static
addCacheOption()

Adds the standard cache control option to the current command.

 : static
isCacheEnabled()

Resolves whether cache writes SHOULD be enabled for the current invocation.

 : bool
resolveCacheArgument()

Returns the explicit cache flag that SHOULD be forwarded to nested commands.

 : string|null
resolveCacheDirArgument()

Resolves a nested cache directory for a child command.

 : string|null
hasExplicitCacheDirArgument()

Determines whether the current invocation explicitly passed `--cache-dir`.

 : bool
isNoCacheRequested()

Determines whether cache writes were explicitly disabled for the current invocation.

 : bool
Methods

addCacheDirOption()

Protected

Adds the standard cache directory option to the current command.

protected addCacheDirOption( string  $description, string  $default) : static
Parameters
$description : string

Description

the cache directory option description

$default : string

Description

the command-specific default cache directory

Return values
static

addCacheOption()

Protected

Adds the standard cache control option to the current command.

protected addCacheOption( string  $description) : static
Parameters
$description : string

Description

the cache option description

Return values
static

isCacheEnabled()

Protected

Resolves whether cache writes SHOULD be enabled for the current invocation.

protected isCacheEnabled(InputInterface  $input[, bool  $default = true]) : bool
Parameters
$input : InputInterface

Description

the current command input

$default : bool = true

Description

the command-specific default cache behavior when the option is omitted

Return values
bool

resolveCacheArgument()

Protected

Returns the explicit cache flag that SHOULD be forwarded to nested commands.

protected resolveCacheArgument(InputInterface  $input) : string|null
Parameters
$input : InputInterface

Description

the current command input

Return values
string|null

resolveCacheDirArgument()

Protected

Resolves a nested cache directory for a child command.

protected resolveCacheDirArgument(InputInterface  $input[, string  $path = '']) : string|null
Parameters
$input : InputInterface

Description

the current command input

$path : string = ''

Description

the child cache path relative to the current command cache root

Return values
string|null

hasExplicitCacheDirArgument()

Private

Determines whether the current invocation explicitly passed `--cache-dir`.

private hasExplicitCacheDirArgument(InputInterface  $input) : bool
Parameters
$input : InputInterface

Description

the current command input

Return values
bool

isNoCacheRequested()

Private

Determines whether cache writes were explicitly disabled for the current invocation.

private isNoCacheRequested(InputInterface  $input) : bool

Description

The Composer application already provides a global --no-cache flag, so commands SHALL reuse that switch instead of redefining a local negated variant.

Parameters
$input : InputInterface

Description

the current command input

Return values
bool