Passed
Push — master ( 1846e8...5b2152 )
by Luiz Kim
06:26 queued 04:04
created

OrderService   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 29
c 2
b 0
f 0
dl 0
loc 55
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A secutiryFilter() 0 21 4
A createOrder() 0 17 1
A __construct() 0 8 1
1
<?php
2
3
namespace ControleOnline\Service;
4
5
use ControleOnline\Entity\Order;
6
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...
7
use ControleOnline\Entity\Status;
8
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...
9
use Symfony\Component\Security\Core\Security;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Core\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...
10
use Doctrine\ORM\QueryBuilder;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\QueryBuilder 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 Symfony\Component\HttpFoundation\RequestStack;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\RequestStack 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 OrderService
14
{
15
    private $request;
16
17
    public function __construct(
18
        private EntityManagerInterface $manager,
19
        private Security $security,
20
        private PeopleService $PeopleService,
0 ignored issues
show
Bug introduced by
The type ControleOnline\Service\PeopleService 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...
21
        RequestStack $requestStack
22
23
    ) {
24
        $this->request  = $requestStack->getCurrentRequest();
25
    }
26
27
28
    public function createOrder(People $receiver, People $payer)
29
    {
30
31
        $order = new Order();
32
        $order->setProvider($receiver);
33
        $order->setClient($payer);
34
        $order->setPayer($payer);
35
        $order->setOrderType('sales');
36
        $order->setOrderStatus($this->manager->getRepository(Status::class)->findOneBy([
0 ignored issues
show
Bug introduced by
The method setOrderStatus() does not exist on ControleOnline\Entity\Order. Did you maybe mean setStatus()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $order->/** @scrutinizer ignore-call */ 
37
                setOrderStatus($this->manager->getRepository(Status::class)->findOneBy([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            'status' => 'open',
38
            'context' => 'order',
39
            'people' => $receiver
40
        ]));
41
        $order->setApp('Asaas');
42
        $this->manager->persist($order);
43
        $this->manager->flush();
44
        return $order;
45
    }
46
47
    public function secutiryFilter(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void
0 ignored issues
show
Unused Code introduced by
The parameter $resourceClass is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
    public function secutiryFilter(QueryBuilder $queryBuilder, /** @scrutinizer ignore-unused */ $resourceClass = null, $applyTo = null, $rootAlias = null): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $applyTo is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
    public function secutiryFilter(QueryBuilder $queryBuilder, $resourceClass = null, /** @scrutinizer ignore-unused */ $applyTo = null, $rootAlias = null): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
        $companies   = $this->PeopleService->getMyCompanies();
50
51
        if ($invoice = $this->request->query->get('invoiceId', null)) {
52
            $queryBuilder->join(sprintf('%s.invoice', $rootAlias), 'OrderInvoice');
53
            $queryBuilder->andWhere(sprintf('OrderInvoice.invoice IN(:invoice)', $rootAlias, $rootAlias));
54
            $queryBuilder->setParameter('invoice', $invoice);
55
        }
56
57
        $queryBuilder->andWhere(sprintf('%s.client IN(:companies) OR %s.provider IN(:companies)', $rootAlias, $rootAlias));
58
        $queryBuilder->setParameter('companies', $companies);
59
60
        if ($provider = $this->request->query->get('provider', null)) {
61
            $queryBuilder->andWhere(sprintf('%s.provider IN(:provider)', $rootAlias));
62
            $queryBuilder->setParameter('provider', preg_replace("/[^0-9]/", "", $provider));
63
        }
64
65
        if ($client = $this->request->query->get('client', null)) {
66
            $queryBuilder->andWhere(sprintf('%s.client IN(:client)', $rootAlias));
67
            $queryBuilder->setParameter('client', preg_replace("/[^0-9]/", "", $client));
68
        }
69
    }
70
}
71