vendor/contao/core-bundle/src/Framework/Adapter.php line 44

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of Contao.
  5. *
  6. * (c) Leo Feyer
  7. *
  8. * @license LGPL-3.0-or-later
  9. */
  10. namespace Contao\CoreBundle\Framework;
  11. /**
  12. * Wraps legacy classes and delegates the method calls, which allows mocking
  13. * these classes in the unit tests.
  14. *
  15. * @template T
  16. * @mixin T
  17. *
  18. * @internal Do not use this class in your code; use ContaoFramework::getAdapter() instead
  19. */
  20. class Adapter
  21. {
  22. /**
  23. * @var class-string<T>
  24. */
  25. private string $class;
  26. /**
  27. * @param class-string<T> $class
  28. */
  29. public function __construct(string $class)
  30. {
  31. $this->class = $class;
  32. }
  33. /**
  34. * Calls a method of the adapted class.
  35. *
  36. * @return mixed
  37. */
  38. public function __call(string $name, array $arguments)
  39. {
  40. return \call_user_func_array([$this->class, $name], $arguments);
  41. }
  42. }