Passed
Push — main ( bd03c4...c6ca62 )
by De Cramer
04:36
created

DeleteEntityForOldExecutionOperation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processData() 0 9 1
A __construct() 0 3 1
1
<?php
2
3
4
namespace Oliverde8\PhpEtlBundle\Etl\Operation\Cleanup;
5
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Oliverde8\Component\PhpEtl\ChainOperation\AbstractChainOperation;
9
use Oliverde8\Component\PhpEtl\Item\ItemInterface;
10
use Oliverde8\PhpEtlBundle\Entity\EtlExecution;
11
12
class DeleteEntityForOldExecutionOperation extends AbstractChainOperation
13
{
14
    /** @var EntityManagerInterface  */
15
    protected EntityManagerInterface $em;
16
17
    /**
18
     * DeleteEntityForOldExecutionOperation constructor.
19
     * @param EntityManagerInterface $em
20
     */
21
    public function __construct(EntityManagerInterface $em)
22
    {
23
        $this->em = $em;
24
    }
25
26
    protected function processData(ItemInterface $item, array &$context)
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

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

26
    protected function processData(ItemInterface $item, /** @scrutinizer ignore-unused */ array &$context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
        /** @var EtlExecution $entity */
29
        $entity = $item->getData();
0 ignored issues
show
Bug introduced by
The method getData() does not exist on Oliverde8\Component\PhpEtl\Item\ItemInterface. It seems like you code against a sub-type of Oliverde8\Component\PhpEtl\Item\ItemInterface such as Oliverde8\Component\PhpEtl\Item\DataItemInterface. ( Ignorable by Annotation )

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

29
        /** @scrutinizer ignore-call */ 
30
        $entity = $item->getData();
Loading history...
30
31
        $this->em->remove($entity);
32
        $this->em->flush();
33
        // Method is currently deprecated but has been un-deprecated it doctrine 3.
34
        $this->em->detach($entity);
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\Persistence\ObjectManager::detach() has been deprecated: Detach operation is deprecated and will be removed in Persistence 2.0. Please use {@see ObjectManager::clear()} instead. ( Ignorable by Annotation )

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

34
        /** @scrutinizer ignore-deprecated */ $this->em->detach($entity);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
35
    }
36
37
}