-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppOutput.php
More file actions
61 lines (55 loc) · 1.07 KB
/
AppOutput.php
File metadata and controls
61 lines (55 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Class Output.
*
* Covers the output to the operating system - console and file.
*/
class AppOutput
{
/**
* @var resource
*/
protected $stdOut;
/**
* @var resource
*/
protected $stdErr;
/**
* Output constructor.
*/
public function __construct()
{
$this->stdOut = 'php://stdout';
$this->stdErr = 'php://stderr';
}
/**
* Write to the stdout
*
* @param $text
* @param bool $addEol
*/
public function writeStdout($text, $addEol = true)
{
$this->writeToFile($this->stdOut, $text.($addEol ? PHP_EOL : ''));
}
/**
* Write to the stdout
*
* @param $text
* @param bool $addEol
*/
public function writeStderr($text, $addEol = true)
{
$this->writeToFile($this->stdErr, $text.($addEol ? PHP_EOL : ''));
}
/**
* @param $fileName
* @param $xml
*
* @return int|bool
*/
public function writeToFile($fileName, $xml)
{
return file_put_contents($fileName, $xml);
}
}