Skip to content

Commit

Permalink
Create rating factory
Browse files Browse the repository at this point in the history
  • Loading branch information
KoukiFactori committed Feb 8, 2023
1 parent 229a3a8 commit 19d2c25
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/Factory/RatingFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace App\Factory;

use App\Entity\Rating;
use App\Repository\RatingRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
* @extends ModelFactory<Rating>
*
* @method Rating|Proxy create(array|callable $attributes = [])
* @method static Rating|Proxy createOne(array $attributes = [])
* @method static Rating|Proxy find(object|array|mixed $criteria)
* @method static Rating|Proxy findOrCreate(array $attributes)
* @method static Rating|Proxy first(string $sortedField = 'id')
* @method static Rating|Proxy last(string $sortedField = 'id')
* @method static Rating|Proxy random(array $attributes = [])
* @method static Rating|Proxy randomOrCreate(array $attributes = [])
* @method static RatingRepository|RepositoryProxy repository()
* @method static Rating[]|Proxy[] all()
* @method static Rating[]|Proxy[] createMany(int $number, array|callable $attributes = [])
* @method static Rating[]|Proxy[] createSequence(array|callable $sequence)
* @method static Rating[]|Proxy[] findBy(array $attributes)
* @method static Rating[]|Proxy[] randomRange(int $min, int $max, array $attributes = [])
* @method static Rating[]|Proxy[] randomSet(int $number, array $attributes = [])
*/
final class RatingFactory extends ModelFactory
{
/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
*
* @todo inject services if required
*/
public function __construct()
{
parent::__construct();
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
*
* @todo add your default values here
*/
protected function getDefaults(): array
{
return [
'bookmark' => BookmarkFactory::new(),
'user' => UserFactory::new(),
'value' => self::faker()->numberBetween(1, 10),
];
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
*/
protected function initialize(): self
{
return $this
// ->afterInstantiate(function(Rating $rating): void {})
;
}

protected static function getClass(): string
{
return Rating::class;
}
}

0 comments on commit 19d2c25

Please sign in to comment.