Issues (68)

src/Controller/CreateNFeAction.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace ControleOnline\Controller;
4
5
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
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
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
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;
10
11
class CreateNFeAction
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