Factory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
namespace Isolate\Framework\UnitOfWork;
4
5
use Isolate\Framework\UnitOfWork\Entity\DefinitionCollection;
6
use Isolate\Framework\UnitOfWork\Entity\IsolateComparer;
7
use Isolate\Framework\UnitOfWork\Entity\IsolateIdentifier;
8
use Isolate\Framework\UnitOfWork\Object\IsolateRegistry;
9
use Isolate\UnitOfWork\CommandBus\SilentBus;
10
use Isolate\UnitOfWork\Entity\ChangeBuilder;
11
use Isolate\UnitOfWork\Entity\Definition\Repository\InMemory;
12
use Isolate\UnitOfWork\Factory as UnitOfWorkFactory;
13
use Isolate\UnitOfWork\Object\PropertyCloner;
14
use Isolate\UnitOfWork\Object\SnapshotMaker\Adapter\DeepCopy\SnapshotMaker;
15
use Isolate\UnitOfWork\UnitOfWork;
16
17
class Factory implements UnitOfWorkFactory
18
{
19
    /**
20
     * @var DefinitionCollection
21
     */
22
    private $entityDefinitions;
23
24
    /**
25
     * @param DefinitionCollection $entityDefinitions
26
     */
27
    public function __construct(DefinitionCollection $entityDefinitions)
28
    {
29
        $this->entityDefinitions = $entityDefinitions;
30
    }
31
32
    /**
33
     * @return UnitOfWork
34
     */
35
    public function create()
36
    {
37
        $definitionRepository = new InMemory($this->entityDefinitions);
0 ignored issues
show
Documentation introduced by
$this->entityDefinitions is of type object<Isolate\Framework...y\DefinitionCollection>, but the function expects a array.

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...
38
        $snapshotMaker = new SnapshotMaker();
39
        $recoveryPoint = new PropertyCloner();
40
        $objectRegistry = new IsolateRegistry($snapshotMaker, $recoveryPoint);
41
        $identifier = new IsolateIdentifier($definitionRepository);
42
        $changeBuilder = new ChangeBuilder($definitionRepository, $identifier);
43
        $comparer = new IsolateComparer($definitionRepository);
44
        $commandBus = new SilentBus($definitionRepository);
45
46
        return new UnitOfWork(
47
            $objectRegistry,
48
            $identifier,
49
            $changeBuilder,
50
            $comparer,
51
            $commandBus
52
        );
53
    }
54
}