1 | <?php |
||
64 | class StdinHandler |
||
65 | { |
||
66 | protected $path; |
||
67 | protected $stream; |
||
68 | |||
69 | /** |
||
70 | * hasPath returns 'true' if the stdin handler has a path to a file. |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function hasPath() |
||
79 | |||
80 | /** |
||
81 | * hasStream returns 'true' if the stdin handler has opened a stream. |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function hasStream() |
||
89 | |||
90 | /** |
||
91 | * path returns the path to any file that was set as a redirection |
||
92 | * source, or `php://stdin` if none have been. |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function path() |
||
100 | |||
101 | /** |
||
102 | * close closes the input stream if it was opened. |
||
103 | */ |
||
104 | public function close() |
||
112 | |||
113 | /** |
||
114 | * redirect specifies a path to a file that should serve as the |
||
115 | * source to read from. If the input path is '-' or empty, |
||
116 | * then output will be taken from php://stdin (or whichever source |
||
117 | * was provided via the 'redirect' method). |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function redirect($path) |
||
129 | |||
130 | /** |
||
131 | * select chooses the source of the input stream based on whether or |
||
132 | * not the user provided the specified option or argument on the commandline. |
||
133 | * Stdin is selected if there is no user selection. |
||
134 | * |
||
135 | * @param InputInterface $input |
||
136 | * @param string $optionOrArg |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function select(InputInterface $input, $optionOrArg) |
||
148 | |||
149 | /** |
||
150 | * getStream opens and returns the stdin stream (or redirect file). |
||
151 | */ |
||
152 | public function getStream() |
||
159 | |||
160 | /** |
||
161 | * setStream functions like 'select', and also sets up the $input |
||
162 | * object to read from the selected input stream e.g. when used |
||
163 | * with a question helper. |
||
164 | */ |
||
165 | public function setStream(InputInterface $input, $optionOrArg) |
||
174 | |||
175 | /** |
||
176 | * contents reads the entire contents of the standard input stream. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public function contents() |
||
194 | |||
195 | protected function getOptionOrArg(InputInterface $input, $optionOrArg) |
||
202 | } |
||
203 |