MatchedRoute.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Knuckles\Scribe\Matching;
  3. use Illuminate\Routing\Route;
  4. class MatchedRoute implements \ArrayAccess
  5. {
  6. /**
  7. * @var Route
  8. */
  9. protected $route;
  10. /**
  11. * @var array
  12. */
  13. protected $rules;
  14. /**
  15. * Match constructor.
  16. *
  17. * @param Route $route
  18. * @param array $applyRules
  19. */
  20. public function __construct(Route $route, array $applyRules)
  21. {
  22. $this->route = $route;
  23. $this->rules = $applyRules;
  24. }
  25. /**
  26. * @return Route
  27. */
  28. public function getRoute()
  29. {
  30. return $this->route;
  31. }
  32. /**
  33. * @return array
  34. */
  35. public function getRules()
  36. {
  37. return $this->rules;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function offsetExists($offset)
  43. {
  44. return is_callable([$this, 'get' . ucfirst($offset)]);
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function offsetGet($offset)
  50. {
  51. return call_user_func([$this, 'get' . ucfirst($offset)]);
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function offsetSet($offset, $value)
  57. {
  58. $this->$offset = $value;
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function offsetUnset($offset)
  64. {
  65. $this->$offset = null;
  66. }
  67. }