DefaultGenerator.php 827 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Faker;
  3. /**
  4. * This generator returns a default value for all called properties
  5. * and methods. It works with Faker\Generator\Base->optional().
  6. *
  7. * @mixin Generator
  8. */
  9. class DefaultGenerator
  10. {
  11. protected $default;
  12. public function __construct($default = null)
  13. {
  14. $this->default = $default;
  15. }
  16. /**
  17. * @param string $attribute
  18. *
  19. * @deprecated Use a method instead.
  20. */
  21. public function __get($attribute)
  22. {
  23. trigger_deprecation('fakerphp/faker', '1.14', 'Accessing property "%s" is deprecated, use "%s()" instead.', $attribute, $attribute);
  24. return $this->default;
  25. }
  26. /**
  27. * @param string $method
  28. * @param array $attributes
  29. */
  30. public function __call($method, $attributes)
  31. {
  32. return $this->default;
  33. }
  34. }