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

DashboardStatisticsProvider::getStatistics()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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