Toolkit

GitHooksCommands extends AbstractCommands
in package

Provides commands to interact with git hooks.

Tags
SuppressWarnings

("unused")

Table of Contents

getConfigurationFile()  : string
Path to YAML configuration file containing command defaults.
getWorkingDir()  : string
Returns the current working directory.
hooksDeleteAll()  : mixed
Remove all existing hooks, this will ignore active hooks list.
hooksDisable()  : int
Disable the git hooks.
hooksEnable()  : int
Enable the git hooks defined in the configuration or in given option.
hooksList()  : mixed
List available hooks and its status.
hooksRun()  : int
Run a specific hook.
initializeRuntimeConfiguration()  : mixed
Command initialization.
getBin()  : string
Validate and return the path to given bin.
getBinPath()  : string
Return the path to given bin.
getConfigValue()  : mixed
{@inheritdoc}
getNodeBin()  : string
Validate and return the path to given bin from node packages.
getNodeBinPath()  : string
Return the path to given bin from node packages.
isSimulating()  : bool
Check if current command is being executed with option simulate.
taskExecute()  : mixed
Execute a command.
taskProcess()  : Process|CollectionBuilder
Process the file.
taskReplaceBlock()  : ReplaceBlock|CollectionBuilder
Replace block in a file.
convertHookToMethod()  : false|string
Converts a hook name to method name.
getAvailableHooks()  : array<string|int, mixed>
Return the available hooks from Toolkit and Project.
getHookFiles()  : array<string|int, mixed>
Return the hooks present in given directory.
runPreCommit()  : mixed
Hook: Executes the PHPcs against the modified files.
runPrepareCommitMsg()  : mixed
Hook: Executes the prepare-commit-msg conditions.
runPrePush()  : mixed
Hook: Executes the pre-push commands.

Methods

getConfigurationFile()

Path to YAML configuration file containing command defaults.

public getConfigurationFile() : string
Return values
string

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string

The current working directory.

hooksDeleteAll()

Remove all existing hooks, this will ignore active hooks list.

public hooksDeleteAll(ConsoleIO $io) : mixed
Parameters
$io : ConsoleIO
Tags
command

toolkit:hooks-delete-all

Return values
mixed

hooksDisable()

Disable the git hooks.

public hooksDisable(ConsoleIO $io[, array<string|int, mixed> $options = ['hooks' => InputOption::VALUE_REQUIRED] ]) : int
Parameters
$io : ConsoleIO
$options : array<string|int, mixed> = ['hooks' => InputOption::VALUE_REQUIRED]

Command options.

Tags
command

toolkit:hooks-disable

option

hooks The hooks to disable (default: toolkit.git.hooks)

Return values
int

The exit code.

hooksEnable()

Enable the git hooks defined in the configuration or in given option.

public hooksEnable(ConsoleIO $io[, array<string|int, mixed> $options = ['hooks' => InputOption::VALUE_REQUIRED] ]) : int
Parameters
$io : ConsoleIO
$options : array<string|int, mixed> = ['hooks' => InputOption::VALUE_REQUIRED]

Command options.

Tags
command

toolkit:hooks-enable

option

hooks The hooks to enable (default: toolkit.hooks.active)

usage

--hooks=pre-push

Return values
int

The exit code.

hooksList()

List available hooks and its status.

public hooksList(ConsoleIO $io) : mixed
Parameters
$io : ConsoleIO
Tags
command

toolkit:hooks-list

SuppressWarnings

(PHPMD.CyclomaticComplexity)

SuppressWarnings

(PHPMD.NPathComplexity)

Return values
mixed

hooksRun()

Run a specific hook.

public hooksRun(ConsoleIO $io, string $hook[, string $arg1 = '' ][, string $arg2 = '' ][, string $arg3 = '' ]) : int
Parameters
$io : ConsoleIO
$hook : string

The hook to run.

$arg1 : string = ''

The first argument of the given hook.

$arg2 : string = ''

The second argument of the given hook.

$arg3 : string = ''

The third argument of the given hook.

Tags
command

toolkit:hooks-run

Return values
int

The exit code.

initializeRuntimeConfiguration()

Command initialization.

public initializeRuntimeConfiguration() : mixed
Tags
hook

pre-command-event *

Return values
mixed

getBin()

Validate and return the path to given bin.

protected getBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string

The bin path.

getBinPath()

Return the path to given bin.

protected getBinPath(string $name) : string
Parameters
$name : string
Return values
string

The path to given binary.

getConfigValue()

{@inheritdoc}

protected getConfigValue(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null
Return values
mixed

getNodeBin()

Validate and return the path to given bin from node packages.

protected getNodeBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string

The bin path.

getNodeBinPath()

Return the path to given bin from node packages.

protected getNodeBinPath(string $name) : string
Parameters
$name : string
Return values
string

The path to given binary.

isSimulating()

Check if current command is being executed with option simulate.

protected isSimulating() : bool
Return values
bool

True if using --simulate, false otherwise.

taskExecute()

Execute a command.

protected taskExecute(array<string|int, mixed> $tasks) : mixed
Parameters
$tasks : array<string|int, mixed>

An array with tasks to execute.

Return values
mixed

taskProcess()

Process the file.

protected taskProcess(string $source[, string $destination = '' ]) : Process|CollectionBuilder
Parameters
$source : string

The source file to process.

$destination : string = ''

The destination file.

Return values
Process|CollectionBuilder

taskReplaceBlock()

Replace block in a file.

protected taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$filename : string = ''

The file to process.

Return values
ReplaceBlock|CollectionBuilder

convertHookToMethod()

Converts a hook name to method name.

private convertHookToMethod(string $hook) : false|string
Parameters
$hook : string

The hook name to convert.

Return values
false|string

The converted hook name, i.e: the pre-push becomes runPrePush, FALSE if empty hook provided.

getAvailableHooks()

Return the available hooks from Toolkit and Project.

private getAvailableHooks() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of available hooks.

getHookFiles()

Return the hooks present in given directory.

private getHookFiles(string $directory) : array<string|int, mixed>
Parameters
$directory : string

The directory to check for hooks.

Return values
array<string|int, mixed>

An array keyed by hook name and path as value, false if do not exist.

runPreCommit()

Hook: Executes the PHPcs against the modified files.

private runPreCommit() : mixed
Return values
mixed

runPrepareCommitMsg()

Hook: Executes the prepare-commit-msg conditions.

private runPrepareCommitMsg() : mixed
Return values
mixed

runPrePush()

Hook: Executes the pre-push commands.

private runPrePush() : mixed
Return values
mixed

Search results