PersistOperation::getPreEventName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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