Passed
Push — master ( 5ff5e8...5a1b88 )
by Luiz Kim
04:18 queued 02:07
created

DiscoveryCart::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ControleOnline\Controller;
4
5
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...
6
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...
7
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...
8
use ControleOnline\Entity\Order;
9
use ControleOnline\Service\NFeService;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Service\NFeService 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 DiscoveryCart
12
{
13
14
15
16
    public function __construct(
17
        private EntityManagerInterface $manager,
18
        private NFeService $nFeService
19
    ) {}
20
21
22
    public function __invoke(Order $data, Request $request): JsonResponse
23
    {
24
        try {
25
26
            $invoiceTax = $this->nFeService->createNfe($data, 55);
27
            return new JsonResponse([
28
                'response' => [
29
                    'data'    => $data->getId(),
30
                    'invoice_tax' => $invoiceTax->getId(),
31
                    'xml' => $invoiceTax->getInvoice(),
32
                    'count'   => 1,
33
                    'error'   => '',
34
                    'success' => true,
35
                ],
36
            ]);
37
        } catch (\Throwable $th) {
38
            return new JsonResponse([
39
                'response' => [
40
                    'count'   => 0,
41
                    'error'   => $th->getMessage(),
42
                    'file' => $th->getFile(),
43
                    'line' => $th->getLine(),
44
                    'success' => false,
45
                ],
46
            ], 500);
47
        }
48
    }
49
}
50