PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/src/PHPFrame/Utils/Exec.php

https://github.com/chrismcband/PHPFrame
PHP | 79 lines | 22 code | 6 blank | 51 comment | 0 complexity | b921b96c1642d860d2f69a7ed7d656d0 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * PHPFrame/Utils/Exec.php
  4. *
  5. * PHP version 5
  6. *
  7. * @category PHPFrame
  8. * @package Utils
  9. * @author Lupo Montero <lupo@e-noise.com>
  10. * @copyright 2010 The PHPFrame Group
  11. * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  12. * @link http://github.com/PHPFrame/PHPFrame
  13. */
  14. /**
  15. * This is a very simple class that wraps around PHP's exec() function and
  16. * provides an Object Oriented interface to command execution.
  17. *
  18. * @category PHPFrame
  19. * @package Utils
  20. * @author Lupo Montero <lupo@e-noise.com>
  21. * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  22. * @link http://github.com/PHPFrame/PHPFrame
  23. * @since 1.0
  24. */
  25. class PHPFrame_Exec
  26. {
  27. private $_cmd, $_output, $_return_var;
  28. /**
  29. * Constructor. This method instantiates an object of this class and
  30. * executes the command passed in the $cmd argument.
  31. *
  32. * @param string $cmd The command we want to run.
  33. *
  34. * @return void
  35. * @since 1.0
  36. */
  37. public function __construct($cmd)
  38. {
  39. $this->_cmd = (string) $cmd;
  40. exec($this->_cmd, $this->_output, $this->_return_var);
  41. }
  42. /**
  43. * Get the command that was run when constructing this object.
  44. *
  45. * @return string
  46. * @since 1.0
  47. */
  48. public function getCmd()
  49. {
  50. return $this->_cmd;
  51. }
  52. /**
  53. * Get output as array of strings. Each entry in the array is a line in the
  54. * output produced by the command.
  55. *
  56. * @return array
  57. * @since 1.0
  58. */
  59. public function getOutput()
  60. {
  61. return $this->_output;
  62. }
  63. /**
  64. * Get return var. This method returns the exit status of the command.
  65. *
  66. * @return int|string
  67. * @since 1.0
  68. */
  69. public function getReturnVar()
  70. {
  71. return $this->_return_var;
  72. }
  73. }