Passed
Pull Request — master (#81)
by
unknown
04:28 queued 47s
created

WishlistExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 24
rs 10
c 2
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 4 1
A injectWishlists() 0 6 1
A __construct() 0 5 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\Twig;
12
13
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface;
14
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface;
15
use http\Env\Response;
16
use Twig\Extension\AbstractExtension;
17
use Twig\TwigFunction;
18
19
class WishlistExtension extends AbstractExtension
20
{
21
    private WishlistRepositoryInterface $wishlistRepository;
22
23
    public function __construct(
24
25
        WishlistRepositoryInterface $wishlistRepository
26
    ) {
27
        $this->wishlistRepository = $wishlistRepository;
28
    }
29
30
    public function getFunctions()
31
    {
32
        return [
33
            new TwigFunction('injectWishlists', [$this, 'injectWishlists']),
34
        ];
35
    }
36
37
    public function injectWishlists()
38
    {
39
        /** @var WishlistInterface $wishlists */
40
        $wishlists = $this->wishlistRepository->findAll();
41
42
        return $wishlists;
43
    }
44
}