Total Complexity | 3 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | trait BrandAwareExampleFactoryTrait |
||
14 | { |
||
15 | /** @var BrandRepositoryInterface */ |
||
16 | protected $brandRepository; |
||
17 | |||
18 | public function __construct(BrandRepositoryInterface $brandRepository) |
||
19 | { |
||
20 | $this->brandRepository = $brandRepository; |
||
21 | } |
||
22 | |||
23 | protected function configureBrandOptions(OptionsResolver $resolver, int $chanceOfRandomBrand = 90): void |
||
24 | { |
||
25 | $resolver |
||
26 | ->setDefault('brand', LazyOption::randomOneOrNull($this->brandRepository, $chanceOfRandomBrand)) |
||
27 | ->setAllowedTypes('brand', ['null', 'string', BrandInterface::class]) |
||
28 | ->setNormalizer('brand', LazyOption::findOneBy($this->brandRepository, 'code')) |
||
29 | ; |
||
30 | } |
||
31 | |||
32 | protected function setBrandField(BrandAwareInterface $brandAware, array $resolvedOptions = []): void |
||
35 | } |
||
36 | } |
||
37 |