Completed
Push — master ( d54afb...01173a )
by Kamil
26:45
created

DashboardStatisticsProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getStatistics() 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\Order\Repository\OrderRepositoryInterface;
15
use Sylius\Component\User\Repository\CustomerRepositoryInterface;
16
17
/**
18
 * @author Paweł Jędrzejewski <[email protected]>
19
 */
20
class DashboardStatisticsProvider implements DashboardStatisticsProviderInterface
21
{
22
    /**
23
     * @var OrderRepositoryInterface
24
     */
25
    private $orderRepository;
26
27
    /**
28
     * @var CustomerRepositoryInterface
29
     */
30
    private $customerRepository;
31
32
    /**
33
     * @param OrderRepositoryInterface $orderRepository
34
     * @param CustomerRepositoryInterface $customerRepository
35
     */
36
    public function __construct(OrderRepositoryInterface $orderRepository, CustomerRepositoryInterface $customerRepository)
37
    {
38
        $this->orderRepository = $orderRepository;
39
        $this->customerRepository = $customerRepository;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getStatistics()
46
    {
47
        return new DashboardStatistics(
48
            $this->orderRepository->getTotalSales(),
49
            $this->orderRepository->count(),
50
            $this->customerRepository->count()
51
        );
52
    }
53
}
54