Passed
Pull Request — master (#80)
by
unknown
07:43 queued 03:32
created

WishlistExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 26
rs 10
c 1
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 6 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
    ) {
28
        $this->wishlistRepository = $wishlistRepository;
29
30
    }
31
32
    public function getFunctions()
33
    {
34
        return [
35
            new TwigFunction('injectWishlists', [$this, 'injectWishlists']),
36
        ];
37
    }
38
39
    public function injectWishlists()
40
    {
41
        /** @var WishlistInterface $wishlists */
42
        $wishlists = $this->wishlistRepository->findAll();
43
44
        return $wishlists;
45
    }
46
}