These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Knp\Rad\FixturesLoad\FixturesFactory; |
||
6 | |||
7 | use Doctrine\Common\Persistence\ObjectManager; |
||
8 | use Knp\Rad\FixturesLoad\FixturesFactory; |
||
9 | use Nelmio\Alice\Fixtures; |
||
10 | use Nelmio\Alice\ProcessorInterface; |
||
11 | |||
12 | class LegacyFactory implements FixturesFactory |
||
13 | { |
||
14 | /** |
||
15 | * @var ProcessorInterface[] |
||
16 | */ |
||
17 | protected $processors = []; |
||
18 | |||
19 | /** |
||
20 | * @var object[] |
||
21 | */ |
||
22 | protected $providers = []; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function addProcessor(ProcessorInterface $processor) |
||
28 | { |
||
29 | $this->processors[] = $processor; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function addProvider($provider) |
||
36 | { |
||
37 | $this->providers[] = $provider; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | View Code Duplication | public function create(ObjectManager $manager, $locale = null): Fixtures |
|
0 ignored issues
–
show
|
|||
44 | { |
||
45 | $options = [ |
||
46 | 'providers' => $this->providers, |
||
47 | ]; |
||
48 | |||
49 | if (null !== $locale) { |
||
50 | $options['locale'] = $locale; |
||
51 | } |
||
52 | |||
53 | return new Fixtures($manager, $options, $this->processors); |
||
54 | } |
||
55 | } |
||
56 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.