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

ChartController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

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