Completed
Push — refactoring-session ( a6dec9 )
by Kamil
06:43
created

StatisticsController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __invoke() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\Bundle\AdminBundle\Controller\Dashboard;
6
7
use Sylius\Component\Core\Dashboard\DashboardStatisticsProviderInterface;
8
use Sylius\Component\Core\Model\ChannelInterface;
9
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
10
use Symfony\Component\HttpFoundation\Response;
11
12
final class StatisticsController
13
{
14
    /** @var EngineInterface */
15
    private $templatingEngine;
16
17
    /** @var DashboardStatisticsProviderInterface */
18
    private $statisticsProvider;
19
20
    public function __construct(
21
        EngineInterface $templatingEngine,
22
        DashboardStatisticsProviderInterface $statisticsProvider
23
    ) {
24
        $this->templatingEngine = $templatingEngine;
25
        $this->statisticsProvider = $statisticsProvider;
26
    }
27
28
    public function __invoke(ChannelInterface $channel): Response
29
    {
30
        return $this->templatingEngine->renderResponse(
31
            '@SyliusAdmin/Dashboard/Statistics/_template.html.twig',
32
            ['statistics' => $this->statisticsProvider->getStatisticsForChannel($channel)]
33
        );
34
    }
35
}
36