Passed
Push — master ( 1d4724...87feaa )
by Luiz Kim
01:43
created

CreateDacteAction::__invoke()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 16
nc 3
nop 2
dl 0
loc 21
rs 9.7333
c 1
b 0
f 0
1
<?php
2
3
namespace ControleOnline\Controller;
4
5
6
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Request 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...
7
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...
8
use Symfony\Component\HttpFoundation\JsonResponse;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\JsonResponse 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 ControleOnline\Entity\Order;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Order 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
use ControleOnline\Service\NFeService;
11
use Symfony\Component\HttpKernel\KernelInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKernel\KernelInterface 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...
12
13
class CreateDacteAction
14
{
15
    /**
16
     * Entity Manager
17
     *
18
     * @var EntityManagerInterface
19
     */
20
    private $manager = null;
21
    private $tools;
0 ignored issues
show
introduced by
The private property $tools is not used, and could be removed.
Loading history...
22
    private $appKernel;
23
24
    public function __construct(EntityManagerInterface $entityManager, KernelInterface $appKernel, private NFeService $nFeService)
25
    {
26
        $this->manager = $entityManager;
27
        $this->appKernel = $appKernel;
28
    }
29
30
31
32
    public function __invoke(Order $data, Request $request): JsonResponse
33
    {
34
        try {
35
36
            $invoiceTax = $this->nFeService->createNfe($data, 57);
37
            return new JsonResponse([
38
                'response' => [
39
                    'data'    => $data->getId(),
40
                    'invoice_tax' => $invoiceTax->getId(),
41
                    'xml' => $invoiceTax->getInvoice(),
42
                    'count'   => 1,
43
                    'error'   => '',
44
                    'success' => true,
45
                ],
46
            ]);
47
        } catch (\Throwable $th) {
48
            return new JsonResponse([
49
                'response' => [
50
                    'count'   => 0,
51
                    'error'   => $th->getMessage(),
52
                    'success' => false,
53
                ],
54
            ]);
55
        }
56
    }
57
}
58