Test Failed
Branch master (fdda4e)
by ANTHONIUS
03:39
created

InteractsWithORM::getEntityManager()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
/*
4
 * This file is part of the EOffice project.
5
 *
6
 * (c) Anthonius Munthi <https://itstoni.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace EOffice\Testing\Concerns;
15
16
use Doctrine\Persistence\ObjectManager;
17
18
trait InteractsWithORM
19
{
20
    protected function getEntityManager(string $class = null): ObjectManager
21
    {
22
        if (null !== $class) {
23
            return $this->getContainer()->get('doctrine')->getManagerForClass($class);
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            return $this->/** @scrutinizer ignore-call */ getContainer()->get('doctrine')->getManagerForClass($class);
Loading history...
24
        }
25
26
        return $this->getContainer()->get('doctrine')->getManager();
27
    }
28
}
29