Passed
Push — master ( 69edb6...1e9864 )
by Luiz Kim
02:26
created

OrderInvoiceService::afterPersist()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 14
rs 9.9332
1
<?php
2
3
namespace ControleOnline\Service;
4
5
use ControleOnline\Entity\OrderInvoice;
6
use ControleOnline\Entity\OrderProduct;
7
use ControleOnline\Entity\Status;
8
use Doctrine\ORM\EntityManagerInterface;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Symfony\Component\Security\Core\Security;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Core\Security was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
class OrderInvoiceService
12
{
13
    public function __construct(
14
        private EntityManagerInterface $manager,
15
        private Security $security
16
    ) {
17
    }
18
19
    public function afterPersist(OrderInvoice $OrderInvoice)
20
    {
21
        $invoice = $OrderInvoice->getInvoice();
22
        $order = $OrderInvoice->getOrder();
23
        if ($invoice->getStatus()->getStatus() == 'Pago') {
24
            $orderStatus = $this->manager->getRepository(Status::class)->findOneBy([
25
                'status' => 'Aguardando Pagamento',
26
                'context' => 'order'
27
            ]);
28
            $order->setStatus($orderStatus);
29
            $this->manager->persist($order);
30
            $this->manager->flush();
31
        }
32
        return $order;
33
    }
34
}
35