PrintController::makePrintDone()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace ControleOnline\Controller;
4
5
use ControleOnline\Entity\Spool;
6
use ControleOnline\Service\HydratorService;
7
use Symfony\Component\Security\Http\Attribute\Security;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Http\Attribute\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...
8
use ControleOnline\Service\PrintService;
9
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...
10
use Exception;
11
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
0 ignored issues
show
Bug introduced by
The type Symfony\Bundle\Framework...ller\AbstractController 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
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...
13
use Symfony\Component\HttpFoundation\Response;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response 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...
14
use Symfony\Component\Routing\Attribute\Route;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Routing\Attribute\Route 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...
15
16
class PrintController extends AbstractController
17
{
18
    public function __construct(
19
        private EntityManagerInterface $manager,
20
        private PrintService $printService,
21
        private HydratorService $hydratorService
22
    ) {}
23
    #[Route('/print/{id}/done', name: "print_done", methods: ["PUT"])]
24
    #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")]
25
    public function makePrintDone(Spool $spool): JsonResponse
26
    {
27
        try {
28
            $spool = $this->printService->makePrintDone($spool);
29
            return new JsonResponse($this->hydratorService->item(Spool::class, $spool->getId(), "spool_item:write"), Response::HTTP_OK);
30
        } catch (Exception $e) {
31
            return new JsonResponse($this->hydratorService->error($e));
32
        }
33
    }
34
}
35