PersonFactory.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Tests\Fixture\Factory\Person;
  3. use App\Entity\Person\Person;
  4. use Zenstruck\Foundry\RepositoryProxy;
  5. use Zenstruck\Foundry\ModelFactory;
  6. use Zenstruck\Foundry\Proxy;
  7. /**
  8. * @extends ModelFactory<Person>
  9. *
  10. * @phpstan-method Person|Proxy create(array|callable $attributes = [])
  11. * @phpstan-method static Person|Proxy createOne(array $attributes = [])
  12. * @phpstan-method static Person|Proxy find(object|array|mixed $criteria)
  13. * @phpstan-method static Person|Proxy findOrCreate(array $attributes)
  14. * @phpstan-method static Person|Proxy first(string $sortedField = 'id')
  15. * @phpstan-method static Person|Proxy last(string $sortedField = 'id')
  16. * @phpstan-method static Person|Proxy random(array $attributes = [])
  17. * @phpstan-method static Person|Proxy randomOrCreate(array $attributes = []))
  18. * @phpstan-method static PersonRepository|RepositoryProxy repository()
  19. * @phpstan-method static Person[]|Proxy[] all()
  20. * @phpstan-method static Person[]|Proxy[] createMany(int $number, array|callable $attributes = [])
  21. * @phpstan-method static Person[]&Proxy[] createSequence(iterable|callable $sequence)
  22. * @phpstan-method static Person[]|Proxy[] findBy(array $attributes)
  23. * @phpstan-method static Person[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
  24. * @phpstan-method static Person[]|Proxy[] randomSet(int $number, array $attributes = []))
  25. */
  26. class PersonFactory extends ModelFactory
  27. {
  28. /**
  29. * @see https://github.com/zenstruck/foundry#factories-as-services
  30. */
  31. public function __construct()
  32. {
  33. parent::__construct();
  34. }
  35. /**
  36. * @see https://github.com/zenstruck/foundry#model-factories
  37. *
  38. * @todo add your default values here
  39. */
  40. protected function getDefaults(): array
  41. {
  42. return [];
  43. }
  44. /**
  45. * @see https://github.com/zenstruck/foundry#initialization
  46. */
  47. protected function initialize(): self
  48. {
  49. return $this
  50. // ->afterInstantiate(function(Post $post) {})
  51. ;
  52. }
  53. protected static function getClass(): string
  54. {
  55. return Person::class;
  56. }
  57. }