ConsoleInput.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. /**
  21. * Object wrapper for interacting with stdin
  22. *
  23. * @package Cake.Console
  24. */
  25. class ConsoleInput {
  26. /**
  27. * Input value.
  28. *
  29. * @var resource
  30. */
  31. protected $_input;
  32. /**
  33. * Constructor
  34. *
  35. * @param string $handle The location of the stream to use as input.
  36. */
  37. public function __construct($handle = 'php://stdin') {
  38. $this->_input = fopen($handle, 'r');
  39. }
  40. /**
  41. * Read a value from the stream
  42. *
  43. * @return mixed The value of the stream
  44. */
  45. public function read() {
  46. return fgets($this->_input);
  47. }
  48. }