HigherOrderTapProxy.php 645 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Illuminate\Support;
  3. class HigherOrderTapProxy
  4. {
  5. /**
  6. * The target being tapped.
  7. *
  8. * @var mixed
  9. */
  10. public $target;
  11. /**
  12. * Create a new tap proxy instance.
  13. *
  14. * @param mixed $target
  15. */
  16. public function __construct($target)
  17. {
  18. $this->target = $target;
  19. }
  20. /**
  21. * Dynamically pass method calls to the target.
  22. *
  23. * @param string $method
  24. * @param array $parameters
  25. * @return mixed
  26. */
  27. public function __call($method, $parameters)
  28. {
  29. $this->target->{$method}(...$parameters);
  30. return $this->target;
  31. }
  32. }