ConsoleInput.php 1.1 KB

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