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.

Provider.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\Run;
  12. use Whoops\RunInterface;
  13. use NunoMaduro\Collision\Contracts\Handler as HandlerContract;
  14. use NunoMaduro\Collision\Contracts\Provider as ProviderContract;
  15. /**
  16. * This is an Collision Provider implementation.
  17. *
  18. * @author Nuno Maduro <enunomaduro@gmail.com>
  19. */
  20. class Provider implements ProviderContract
  21. {
  22. /**
  23. * Holds an instance of the Run.
  24. *
  25. * @var \Whoops\RunInterface
  26. */
  27. protected $run;
  28. /**
  29. * Holds an instance of the handler.
  30. *
  31. * @var \NunoMaduro\Collision\Contracts\Handler
  32. */
  33. protected $handler;
  34. /**
  35. * Creates a new instance of the Provider.
  36. *
  37. * @param \Whoops\RunInterface|null $run
  38. * @param \NunoMaduro\Collision\Contracts\Handler|null $handler
  39. */
  40. public function __construct(RunInterface $run = null, HandlerContract $handler = null)
  41. {
  42. $this->run = $run ?: new Run;
  43. $this->handler = $handler ?: new Handler;
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function register(): ProviderContract
  49. {
  50. $this->run->pushHandler($this->handler)
  51. ->register();
  52. return $this;
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function getHandler(): HandlerContract
  58. {
  59. return $this->handler;
  60. }
  61. }