PersistOperation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 32
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A execute() 0 3 1
A getPreEventName() 0 3 1
A getPostEventName() 0 3 1
A getName() 0 3 1
1
<?php
2
/**
3
 * This file is part of the sauls/object-registry-bundle package.
4
 *
5
 * @author    Saulius Vaičeliūnas <[email protected]>
6
 * @link      http://saulius.vaiceliunas.lt
7
 * @copyright 2018
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Sauls\Bundle\ObjectRegistryBundle\Batch\Operation;
14
15
use Doctrine\ORM\EntityManagerInterface;
16
use Sauls\Bundle\ObjectRegistryBundle\Event\DoctrineObjectEvents;
17
18
class PersistOperation implements OperationInterface
19
{
20
    public const NAME = 'persist';
21
22
    /**
23
     * @var EntityManagerInterface
24
     */
25
    private $entityManager;
26
27 4
    public function __construct(EntityManagerInterface $entityManager)
28
    {
29 4
        $this->entityManager = $entityManager;
30 4
    }
31
32 1
    public function execute(object $object): void
33
    {
34 1
        $this->entityManager->persist($object);
35 1
    }
36
37 1
    public function getName(): string
38
    {
39 1
        return self::NAME;
40
    }
41
42 1
    public function getPreEventName(): string
43
    {
44 1
        return DoctrineObjectEvents::PRE_BATCH_SAVE;
45
    }
46
47 1
    public function getPostEventName(): string
48
    {
49 1
        return DoctrineObjectEvents::POST_BATCH_SAVE;
50
    }
51
}
52