Test Failed
Push — master ( 41e89b...cfe199 )
by ANTHONIUS
04:45 queued 12s
created

InteractsWithOrganization   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A iHaveJabatan() 0 13 2
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 EOffice\Contracts\Organization\Model\JabatanInterface;
17
use EOffice\Organization\Model\Jabatan;
18
19
trait InteractsWithOrganization
20
{
21
    public function iHaveJabatan(string $nama): JabatanInterface
22
    {
23
        $em      = $this->getEntityManager(JabatanInterface::class);
0 ignored issues
show
Bug introduced by
It seems like getEntityManager() 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
        /** @scrutinizer ignore-call */ 
24
        $em      = $this->getEntityManager(JabatanInterface::class);
Loading history...
24
        $jabatan = $em->getRepository(JabatanInterface::class)->findOneBy([
25
            'nama' => $nama,
26
        ]);
27
        if (null === $jabatan) {
28
            $jabatan = new Jabatan($nama);
29
            $em->persist($jabatan);
30
            $em->flush();
31
        }
32
33
        return $jabatan;
34
    }
35
}
36