1: <?php
2: /**
3: * ConsoleInput file.
4: *
5: * PHP 5
6: *
7: * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8: * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
9: *
10: * Licensed under The MIT License
11: * For full copyright and license information, please see the LICENSE.txt
12: * Redistributions of files must retain the above copyright notice.
13: *
14: * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
15: * @link http://cakephp.org CakePHP(tm) Project
16: * @package Cake.Console
17: * @since CakePHP(tm) v 2.0
18: * @license http://www.opensource.org/licenses/mit-license.php MIT License
19: */
20:
21: /**
22: * Object wrapper for interacting with stdin
23: *
24: * @package Cake.Console
25: */
26: class ConsoleInput {
27:
28: /**
29: * Input value.
30: *
31: * @var resource
32: */
33: protected $_input;
34:
35: /**
36: * Constructor
37: *
38: * @param string $handle The location of the stream to use as input.
39: */
40: public function __construct($handle = 'php://stdin') {
41: $this->_input = fopen($handle, 'r');
42: }
43:
44: /**
45: * Read a value from the stream
46: *
47: * @return mixed The value of the stream
48: */
49: public function read() {
50: return fgets($this->_input);
51: }
52:
53: }
54: