ProcessResult.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Illuminate\Contracts\Process;
  3. interface ProcessResult
  4. {
  5. /**
  6. * Get the original command executed by the process.
  7. *
  8. * @return string
  9. */
  10. public function command();
  11. /**
  12. * Determine if the process was successful.
  13. *
  14. * @return bool
  15. */
  16. public function successful();
  17. /**
  18. * Determine if the process failed.
  19. *
  20. * @return bool
  21. */
  22. public function failed();
  23. /**
  24. * Get the exit code of the process.
  25. *
  26. * @return int|null
  27. */
  28. public function exitCode();
  29. /**
  30. * Get the standard output of the process.
  31. *
  32. * @return string
  33. */
  34. public function output();
  35. /**
  36. * Determine if the output contains the given string.
  37. *
  38. * @param string $output
  39. * @return bool
  40. */
  41. public function seeInOutput(string $output);
  42. /**
  43. * Get the error output of the process.
  44. *
  45. * @return string
  46. */
  47. public function errorOutput();
  48. /**
  49. * Determine if the error output contains the given string.
  50. *
  51. * @param string $output
  52. * @return bool
  53. */
  54. public function seeInErrorOutput(string $output);
  55. /**
  56. * Throw an exception if the process failed.
  57. *
  58. * @param callable|null $callback
  59. * @return $this
  60. */
  61. public function throw(?callable $callback = null);
  62. /**
  63. * Throw an exception if the process failed and the given condition is true.
  64. *
  65. * @param bool $condition
  66. * @param callable|null $callback
  67. * @return $this
  68. */
  69. public function throwIf(bool $condition, ?callable $callback = null);
  70. }