RenderHeaderTemplateAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
A __construct() 0 4 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusWishlistPlugin\Controller\Action;
12
13
use BitBag\SyliusWishlistPlugin\Context\WishlistContextInterface;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
use Twig\Environment;
17
18
final class RenderHeaderTemplateAction
19
{
20
    private WishlistContextInterface $wishlistContext;
21
22
    private Environment $twigEnvironment;
23
24
    public function __construct(WishlistContextInterface $wishlistContext, Environment $twigEnvironment)
25
    {
26
        $this->wishlistContext = $wishlistContext;
27
        $this->twigEnvironment = $twigEnvironment;
28
    }
29
30
    public function __invoke(Request $request): Response
31
    {
32
        $wishlist = $this->wishlistContext->getWishlist($request);
33
34
        return new Response(
35
            $this->twigEnvironment->render('@BitBagSyliusWishlistPlugin/Common/widget.html.twig', [
36
                'wishlist' => $wishlist,
37
            ])
38
        );
39
    }
40
}
41