Test Setup Failed
Pull Request — master (#39)
by Pierre
12:34
created

LegacyFactory::addProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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);
0 ignored issues
show
Documentation introduced by
$manager is of type object<Doctrine\Common\Persistence\ObjectManager>, but the function expects a object<Nelmio\Alice\PersisterInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
54
    }
55
}
56