PHP 클래스 Clinner\Command\Callback

This is a command abstraction which actually delegates the execution logic to a callback function. The function will be invoked with an input string argument, and is expected to return an integer value representing the exit code for the command: @param string|null $input The input for the string. @return int The exit code for the command. function callback(string $input); Any output generated to stdout will be buffered as the command's output. Usage examples: Get all the users in the system whose username contains at least one 'a' $systemUsers = Command::create('cat', array('/etc/passwd')) ->pipe( Command::create('grep', array('-v' => '^#'), array('delimiter' => ' ')) ) ->pipe( Command::create('cut', array('-d' => ':', '-f' => 1), array('delimiter' => '')) ) ->pipe($callbackCommand) ->run() ->getOutputAsArray("\n");
저자: José Nahuel Cuesta Luengo ([email protected])
상속: implements Clinner\Command\CommandInterface, implements Clinner\Command\PipingCommandInterface, implements PipeableCommandInterface
파일 보기 프로젝트 열기: ncuesta/clinner 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( Closure $callback ) Constructor.
getCallback ( ) : Closure Get the callback function for this command.
getCallbackCode ( ) : string Get the code of the inner callback as string.
getErrorOutput ( ) : string Get the output for this command's execution.
getExitCode ( ) : integer Get the exit code for this command's execution.
getOutput ( ) : string Get the output for this command's execution.
getPipedCommand ( ) : Clinner\Command\PipeableCommandInterface Get the command piped to this one, if any.
hasPipedCommand ( ) : boolean Answer whether this command has a command piped to it.
pipe ( PipeableCommandInterface $anotherCommand, boolean $appendToPipe = true ) : Clinner\Command\PipingCommandInterface Pipe $anotherCommand to this one, so that this command's output is directly sent to $anotherCommand's standard input.
run ( string $input = null ) : Clinner\Command\CommandInterface Run this command and get the exit code for it.
setCallback ( Closure $callback ) : Callback Set the callback function for this command.
toCommandString ( ) : string Get a string representation of this command with its arguments, as if it would be written in a command-line interface when run.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( Closure $callback )
$callback Closure The callback function.

getCallback() 공개 메소드

Get the callback function for this command.
public getCallback ( ) : Closure
리턴 Closure

getCallbackCode() 공개 메소드

Get the code of the inner callback as string.
public getCallbackCode ( ) : string
리턴 string

getErrorOutput() 공개 메소드

This method will only return a valid value after the command has been executed.
public getErrorOutput ( ) : string
리턴 string

getExitCode() 공개 메소드

This method will only return a valid value after the command has been executed.
public getExitCode ( ) : integer
리턴 integer

getOutput() 공개 메소드

This method will only return a valid value after the command has been executed.
public getOutput ( ) : string
리턴 string

getPipedCommand() 공개 메소드

Get the command piped to this one, if any.
public getPipedCommand ( ) : Clinner\Command\PipeableCommandInterface
리턴 Clinner\Command\PipeableCommandInterface

hasPipedCommand() 공개 메소드

Answer whether this command has a command piped to it.
public hasPipedCommand ( ) : boolean
리턴 boolean

pipe() 공개 메소드

Pipe $anotherCommand to this one, so that this command's output is directly sent to $anotherCommand's standard input.
public pipe ( PipeableCommandInterface $anotherCommand, boolean $appendToPipe = true ) : Clinner\Command\PipingCommandInterface
$anotherCommand PipeableCommandInterface The command to pipe.
$appendToPipe boolean Whether $anotherCommand will be appended to the currently piped commands (TRUE) or if it will be added after this command, rearranging the commands pipe to include it.
리턴 Clinner\Command\PipingCommandInterface This instance, for a fluent API.

run() 공개 메소드

Run this command and get the exit code for it.
public run ( string $input = null ) : Clinner\Command\CommandInterface
$input string (Optional) input string for this command.
리턴 Clinner\Command\CommandInterface This command, for a fluent API.

setCallback() 공개 메소드

Set the callback function for this command.
public setCallback ( Closure $callback ) : Callback
$callback Closure The callback function.
리턴 Callback This instance, for a fluent API.

toCommandString() 공개 메소드

Get a string representation of this command with its arguments, as if it would be written in a command-line interface when run.
public toCommandString ( ) : string
리턴 string