Completed
Push — master ( a13c2f...df1c7f )
by Kamil
9s
created

PhpcrContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A purgeAndInitializeDatabase() 0 9 1
1
<?php
2
3
namespace Tests\Lakion\SyliusCmsBundle\Behat\Context\Hook;
4
5
use Behat\Behat\Context\Context;
6
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
7
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
8
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
9
10
final class PhpcrContext implements Context
11
{
12
    /**
13
     * @var DocumentManagerInterface
14
     */
15
    private $documentManager;
16
17
    /**
18
     * @var InitializerManager
19
     */
20
    private $initializerManager;
21
22
    /**
23
     * @param DocumentManagerInterface $documentManager
24
     * @param InitializerManager $initializerManager
25
     */
26
    public function __construct(DocumentManagerInterface $documentManager, InitializerManager $initializerManager)
27
    {
28
        $this->documentManager = $documentManager;
29
        $this->initializerManager = $initializerManager;
30
    }
31
32
    /**
33
     * @BeforeScenario
34
     */
35
    public function purgeAndInitializeDatabase()
36
    {
37
        $purger = new PHPCRPurger($this->documentManager);
0 ignored issues
show
Documentation introduced by
$this->documentManager is of type object<Doctrine\ODM\PHPC...cumentManagerInterface>, but the function expects a null|object<Doctrine\ODM\PHPCR\DocumentManager>.

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
        $purger->purge();
39
40
        $this->documentManager->clear();
41
42
        $this->initializerManager->initialize();
43
    }
44
}
45