CRM_Utils_ConsoleTee
in package
Capture the output from the console, copy it to a file, and pass it on.
$tee = CRM_Utils_ConsoleTee::create()->start();
echo "hello world";
$tee->stop();
assertEquals("hello world", file_get_contents($tee->getFileName()));
Loosely speaking, it serves a similar purpose to Unix tee
.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- CRM_Utils_ConsoleTee constructor.
- create() : CRM_Utils_ConsoleTee
- Capture console output and copy to a temp file.
- getFileName() : string
- onOutput() : bool
- Process a snippet of data from the output buffer.
- start() : CRM_Utils_ConsoleTee
- Start capturing console output and copying it to a file.
- stop() : CRM_Utils_ConsoleTee
- Stop capturing console output.
Properties
$fh
protected
resource
$fh
$fileName
protected
string
$fileName
Methods
__construct()
CRM_Utils_ConsoleTee constructor.
public
__construct(string $fileName) : mixed
Parameters
- $fileName : string
-
The full path of the file to write to.
create()
Capture console output and copy to a temp file.
public
static create([string $prefix = 'ConsoleTee-' ]) : CRM_Utils_ConsoleTee
Parameters
- $prefix : string = 'ConsoleTee-'
Return values
CRM_Utils_ConsoleTeegetFileName()
public
getFileName() : string
Return values
stringonOutput()
Process a snippet of data from the output buffer.
public
onOutput(string $buf) : bool
Parameters
- $buf : string
Tags
Return values
boolstart()
Start capturing console output and copying it to a file.
public
start([string $mode = 'w' ]) : CRM_Utils_ConsoleTee
Parameters
- $mode : string = 'w'
-
The file output mode, e.g.
w
orw+
.
Tags
Return values
CRM_Utils_ConsoleTeestop()
Stop capturing console output.
public
stop() : CRM_Utils_ConsoleTee