Completed
Push — symfony3-fqcn-sylius-3 ( 1d8d47...2ae323 )
by Kamil
38:58 queued 18:19
created

DashboardStatisticsProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Component\Core\Dashboard;
13
14
use Sylius\Component\Core\Model\ChannelInterface;
15
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
16
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
17
18
/**
19
 * @author Paweł Jędrzejewski <[email protected]>
20
 */
21
class DashboardStatisticsProvider implements DashboardStatisticsProviderInterface
22
{
23
    /**
24
     * @var OrderRepositoryInterface
25
     */
26
    private $orderRepository;
27
28
    /**
29
     * @var CustomerRepositoryInterface
30
     */
31
    private $customerRepository;
32
33
    /**
34
     * @param OrderRepositoryInterface $orderRepository
35
     * @param CustomerRepositoryInterface $customerRepository
36
     */
37
    public function __construct(
38
        OrderRepositoryInterface $orderRepository,
39
        CustomerRepositoryInterface $customerRepository
40
    ) {
41
        $this->orderRepository = $orderRepository;
42
        $this->customerRepository = $customerRepository;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getStatisticsForChannel(ChannelInterface $channel)
49
    {
50
        return new DashboardStatistics(
51
            $this->orderRepository->getTotalSalesForChannel($channel),
52
            $this->orderRepository->countByChannel($channel),
53
            $this->customerRepository->count()
54
        );
55
    }
56
}
57