Passed
Push — master ( 7bc770...7daa7a )
by Luiz Kim
31:44 queued 29:20
created

PurchasingSuggestionController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPurchasingSuggestion() 0 5 1
A printPurchasingSuggestion() 0 8 1
A __construct() 0 4 1
1
<?php
2
3
namespace ControleOnline\Controller;
4
5
use ControleOnline\Entity\Device;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Device 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 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 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 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...
9
use Symfony\Component\Routing\Annotation\Route;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Routing\Annotation\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...
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
0 ignored issues
show
Bug introduced by
The type Sensio\Bundle\FrameworkE...\Configuration\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...
11
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...
12
use ControleOnline\Entity\People;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\People 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 ControleOnline\Service\ProductService;
14
15
class PurchasingSuggestionController extends AbstractController
16
{
17
    public function __construct(
18
        private EntityManagerInterface $manager,
19
        private ProductService $productService
20
    ) {}
21
22
    /**
23
     * @Route("/products/purchasing-suggestion", name="purchasing_suggestion", methods={"GET"})
24
     * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")
25
     */
26
    public function getPurchasingSuggestion(Request $request): JsonResponse
27
    {
28
        $company =  $this->manager->getRepository(People::class)->find($request->get('company'));
29
        $data = $this->productService->getPurchasingSuggestion($company);
30
        return new JsonResponse($data);
31
    }
32
33
    /**
34
     * @Route("/products/purchasing-suggestion/print", name="purchasing_suggestion_print", methods={"POST"})
35
     * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")
36
     */
37
    public function printPurchasingSuggestion(Request $request): JsonResponse
38
    {
39
        $data = json_decode($request->getContent(), true);
40
        $printType = $data['print-type'];
41
        $deviceType = $data['device-type'];
42
        $company = $this->manager->getRepository(People::class)->find($data['people']);
43
        $printData = $this->productService->purchasingSuggestionPrintData($company, $printType, $deviceType);
44
        return new JsonResponse($printData);
45
    }
46
}
47