ConsoleOutput::set_output()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace LibSSH2;
3
4
/**
5
 * ConsoleOutput class.
6
 *
7
 * Setter/getter class for console output.
8
 *
9
 * @package LibSSH2
10
 */
11
class ConsoleOutput
12
{
13
14
    /**
15
     * STDOUT stream.
16
     *
17
     * @var string
18
     */
19
    protected $stdout;
20
21
    /**
22
     * STDERR stream.
23
     *
24
     * @var string
25
     */
26
    protected $stderr;
27
28
    /**
29
     * Exit status code.
30
     *
31
     * @var int
32
     */
33
    protected $exitstatus;
34
    
35
    /**
36
     * Last known error message.
37
     *
38
     * @var string
39
     */
40
    protected $error_message = NULL;
41
    
42
    /**
43
     * Last known error line number.
44
     *
45
     * @var int
46
     */
47
    protected $error_line_no = NULL;
48
    
49
    /**
50
     * Last known error filename.
51
     *
52
     * @var string
53
     */
54
    protected $error_file = NULL;
55
56
    /**
57
     * Set STDOUT output stream.
58
     *
59
     * @param  mixed $stdout standard output
60
     * @return object
61
     */
62
    final public function set_output($stdout)
63
    {
64
        $this->stdout = $stdout;
65
    }
66
67
    /**
68
     * Set STDERR output stream.
69
     *
70
     * @param  string $stderr standard error
71
     * @return object
72
     */
73
    final public function set_error($stderr)
74
    {
75
        $this->stderr = $stderr;
76
    }
77
78
    /**
79
     * Set exit status code.
80
     *
81
     * @param  int $exitstatus exit status code
82
     * @return object
83
     */
84
    final public function set_exitstatus($exitstatus)
85
    {
86
        $this->exitstatus = $exitstatus;
87
    }
88
89
    /**
90
     * Get STDOUT output stream.
91
     *
92
     * @return mixed STDOUT output stream
93
     */
94
    final public function get_output()
95
    {
96
        return $this->stdout;
97
    }
98
99
    /**
100
     * Get STDERR output stream.
101
     *
102
     * @return string STDERR output stream
103
     */
104
    final public function get_error()
105
    {
106
        return $this->stderr;
107
    }
108
109
    /**
110
     * Get exit status code.
111
     *
112
     * @return int
113
     */
114
    final public function get_exitstatus()
115
    {
116
        return $this->exitstatus;
117
    }
118
    
119
    /**
120
     * Get last known 'fatal' error.
121
     *
122
     * @return string
123
     */
124
    final public function get_error_message()
125
    {
126
        $this->error_message = error_get_last()['message'];
127
        return $this->error_message . ' in ' . $this->get_error_file() . ' on line ' . $this->get_error_line();
128
    }
129
    
130
    /**
131
     * Get last known 'fatal' error.
132
     *
133
     * @return string
134
     */
135
    final public function get_error_line()
136
    {
137
        $this->error_line_no = error_get_last()['line'];
138
        return $this->error_line_no;
139
    }
140
    
141
    /**
142
     * Get last known 'fatal' error.
143
     *
144
     * @return string
145
     */
146
    final public function get_error_file()
147
    {
148
        $this->error_file = error_get_last()['file'];
149
        return $this->error_file;
150
    }
151
}
152