MagicianCall.php 716 B

12345678910111213141516171819202122232425262728
  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\Tests\Fixtures;
  11. class MagicianCall
  12. {
  13. private $foobar;
  14. public function __call($name, $args)
  15. {
  16. $property = lcfirst(substr($name, 3));
  17. if ('get' === substr($name, 0, 3)) {
  18. return isset($this->$property) ? $this->$property : null;
  19. } elseif ('set' === substr($name, 0, 3)) {
  20. $value = 1 == count($args) ? $args[0] : null;
  21. $this->$property = $value;
  22. }
  23. }
  24. }