Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Handler.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * This file is part of Collision.
  4. *
  5. * (c) Nuno Maduro <enunomaduro@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace NunoMaduro\Collision;
  11. use Whoops\Handler\Handler as AbstractHandler;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. use NunoMaduro\Collision\Contracts\Writer as WriterContract;
  14. use NunoMaduro\Collision\Contracts\Handler as HandlerContract;
  15. /**
  16. * This is an Collision Handler implementation.
  17. *
  18. * @author Nuno Maduro <enunomaduro@gmail.com>
  19. */
  20. class Handler extends AbstractHandler implements HandlerContract
  21. {
  22. /**
  23. * Holds an instance of the writer.
  24. *
  25. * @var \NunoMaduro\Collision\Contracts\Writer
  26. */
  27. protected $writer;
  28. /**
  29. * Creates an instance of the Handler.
  30. *
  31. * @param \NunoMaduro\Collision\Contracts\Writer|null $writer
  32. */
  33. public function __construct(WriterContract $writer = null)
  34. {
  35. $this->writer = $writer ?: new Writer;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function handle()
  41. {
  42. $this->writer->write($this->getInspector());
  43. return static::QUIT;
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function setOutput(OutputInterface $output): HandlerContract
  49. {
  50. $this->writer->setOutput($output);
  51. return $this;
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function getWriter(): WriterContract
  57. {
  58. return $this->writer;
  59. }
  60. }