GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 9a9dbd...ba2850 )
by
unknown
04:30
created

SalesTotalDataFetcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Odiseo\SyliusReportPlugin\DataFetcher;
4
5
use Exception;
6
use Odiseo\SyliusReportPlugin\Filter\QueryFilter;
7
use Odiseo\SyliusReportPlugin\Form\Type\DataFetcher\SalesTotalType;
8
use Sylius\Component\Core\Model\PaymentInterface;
9
use Sylius\Component\Core\OrderPaymentStates;
10
11
/**
12
 * @author Łukasz Chruściel <[email protected]>
13
 * @author Diego D'amico <[email protected]>
14
 */
15
class SalesTotalDataFetcher extends TimePeriodDataFetcher
16
{
17
    /**
18
     * @var string
19
     */
20
    private $orderClass;
21
22
    /**
23
     * @param QueryFilter $queryFilter
24
     * @param string $orderClass
25
     */
26
    public function __construct(
27
        QueryFilter $queryFilter,
28
        string $orderClass
29
    ) {
30
        parent::__construct($queryFilter);
31
32
        $this->orderClass = $orderClass;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     * @throws Exception
38
     */
39
    protected function setupQueryFilter(array $configuration = []): void
40
    {
41
        $qb = $this->queryFilter->getQueryBuilder();
42
43
        $from = $this->orderClass;
44
        $qb
45
            ->select('DATE(payment.updatedAt) as date', 'COUNT(DATE(payment.updatedAt)) as orders', 'ROUND(SUM(o.total/100), 2) as total_'.$configuration['baseCurrency'])
46
            ->from($from, 'o')
47
        ;
48
49
        $this->queryFilter->addLeftJoin('o.customer', 'c');
50
        $this->queryFilter->addLeftJoin('c.user', 'user');
51
        $this->queryFilter->addLeftJoin('o.payments', 'payment');
52
53
        $qb
54
            ->andWhere('o.paymentState = :paymentState')
55
            ->andWhere('payment.state = :state')
56
            ->setParameter('paymentState', OrderPaymentStates::STATE_PAID)
57
            ->setParameter('state', PaymentInterface::STATE_COMPLETED)
58
        ;
59
60
        $this->queryFilter->addTimePeriod($configuration, 'payment.updatedAt');
61
        $this->queryFilter->addChannel($configuration, 'o.channel');
62
        $this->queryFilter->addUserGender($configuration);
63
        $this->queryFilter->addUserCountry($configuration, 'shipping');
64
        $this->queryFilter->addUserCity($configuration, 'shipping');
65
        $this->queryFilter->addUserProvince($configuration, 'shipping');
66
        $this->queryFilter->addUserPostcode($configuration, 'shipping');
67
        $this->queryFilter->addUserCountry($configuration, 'billing');
68
        $this->queryFilter->addUserCity($configuration, 'billing');
69
        $this->queryFilter->addUserProvince($configuration, 'billing');
70
        $this->queryFilter->addUserPostcode($configuration, 'billing');
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getType(): string
77
    {
78
        return SalesTotalType::class;
79
    }
80
}
81