PHP Class TQ\Vcs\Cli\Call

Mostra file Open project: teqneers/php-stream-wrapper-for-git Class Usage Examples

Protected Properties

Property Type Description
$cmd string The CLI command to execute
$cwd string | null The working directory in which the call will be executed
$env array | null Environment variables - defaults to the current environment

Public Methods

Method Description
__construct ( string $cmd, string | null $cwd = null, array $env = null ) Creates a new instance of a CLI call
create ( string $cmd, string | null $cwd = null, array $env = null ) : static Factory method to create a call
execute ( string | null $stdIn = null ) : CallResult Executes the call using the preconfigured command
getCmd ( ) : string Returns the CLI command
getCwd ( ) : string | null Returns the working directory for the call
getEnv ( ) : array | null Returns the environment variables for the call - if overridden
setCmd ( string $cmd ) : Call Sets the CLI command
setCwd ( string | null $cwd ) : Call Sets the working directory for the call
setEnv ( array $env = null ) : Call Sets the environment variables for the call

Method Details

__construct() public method

Creates a new instance of a CLI call
public __construct ( string $cmd, string | null $cwd = null, array $env = null )
$cmd string The CLI command to execute
$cwd string | null The working directory in which the call will be executed
$env array Environment variables - defaults to the current environment

create() public static method

Factory method to create a call
public static create ( string $cmd, string | null $cwd = null, array $env = null ) : static
$cmd string The CLI command to execute
$cwd string | null The working directory in which the call will be executed
$env array Environment variables - defaults to the current environment
return static

execute() public method

Executes the call using the preconfigured command
public execute ( string | null $stdIn = null ) : CallResult
$stdIn string | null Content that will be piped to the command
return CallResult

getCmd() public method

Returns the CLI command
public getCmd ( ) : string
return string

getCwd() public method

Returns the working directory for the call
public getCwd ( ) : string | null
return string | null

getEnv() public method

Returns the environment variables for the call - if overridden
public getEnv ( ) : array | null
return array | null

setCmd() public method

Sets the CLI command
public setCmd ( string $cmd ) : Call
$cmd string The CLI command to execute
return Call

setCwd() public method

Sets the working directory for the call
public setCwd ( string | null $cwd ) : Call
$cwd string | null The working directory in which the call will be executed
return Call

setEnv() public method

Sets the environment variables for the call
public setEnv ( array $env = null ) : Call
$env array Environment variables - defaults to the current environment
return Call

Property Details

$cmd protected_oe property

The CLI command to execute
protected string $cmd
return string

$cwd protected_oe property

The working directory in which the call will be executed
protected string|null $cwd
return string | null

$env protected_oe property

Environment variables - defaults to the current environment
protected array|null $env
return array | null