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

DashboardStatisticsProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getStatisticsForChannel() 0 8 1
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