PropertyAccessorBuilder.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\PropertyAccess;
  11. /**
  12. * A configurable builder for PropertyAccessorInterface objects.
  13. *
  14. * @author Jérémie Augustin <jeremie.augustin@pixel-cookers.com>
  15. */
  16. class PropertyAccessorBuilder
  17. {
  18. /**
  19. * @var Boolean
  20. */
  21. private $magicCall = false;
  22. /**
  23. * Enables the use of "__call" by the ProperyAccessor.
  24. *
  25. * @return PropertyAccessorBuilder The builder object
  26. */
  27. public function enableMagicCall()
  28. {
  29. $this->magicCall = true;
  30. return $this;
  31. }
  32. /**
  33. * Disables the use of "__call" by the ProperyAccessor.
  34. *
  35. * @return PropertyAccessorBuilder The builder object
  36. */
  37. public function disableMagicCall()
  38. {
  39. $this->magicCall = false;
  40. return $this;
  41. }
  42. /**
  43. * @return Boolean true if the use of "__call" by the ProperyAccessor is enabled
  44. */
  45. public function isMagicCallEnabled()
  46. {
  47. return $this->magicCall;
  48. }
  49. /**
  50. * Builds and returns a new propertyAccessor object.
  51. *
  52. * @return PropertyAccessorInterface The built propertyAccessor
  53. */
  54. public function getPropertyAccessor()
  55. {
  56. return new PropertyAccessor($this->magicCall);
  57. }
  58. }