Completed
Push — master ( 31741c...acf815 )
by Benjamin
11:01 queued 06:10
created

AssetsExtension   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 16
c 1
b 0
f 0
dl 0
loc 45
ccs 0
cts 20
cp 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 8 1
A getTeamCover() 0 3 1
A __construct() 0 4 1
A getObblmCss() 0 3 1
A getTeamLogo() 0 3 1
A getRosterImageUrl() 0 3 1
A getObblmJs() 0 3 1
1
<?php
2
3
namespace Obblm\Core\Twig;
4
5
use Obblm\Core\Entity\Rule;
6
use Obblm\Core\Entity\Team;
7
use Obblm\Core\Helper\AssetPackager;
8
use Obblm\Core\Helper\ImageHelper;
9
use Twig\Extension\AbstractExtension;
10
use Twig\TwigFunction;
11
12
class AssetsExtension extends AbstractExtension
13
{
14
    protected $imageHelper;
15
    protected $packager;
16
17
    public function __construct(AssetPackager $packager, ImageHelper $imageHelper)
18
    {
19
        $this->packager = $packager;
20
        $this->imageHelper = $imageHelper;
21
    }
22
23
    public function getFunctions()
24
    {
25
        return [
26
            new TwigFunction('roster_image', [$this, 'getRosterImageUrl']),
27
            new TwigFunction('team_logo', [$this, 'getTeamLogo']),
28
            new TwigFunction('team_cover', [$this, 'getTeamCover']),
29
            new TwigFunction('obblm_css', [$this, 'getObblmCss']),
30
            new TwigFunction('obblm_js', [$this, 'getObblmJs']),
31
        ];
32
    }
33
34
    public function getObblmCss(string $entrypoint, $bundle = 'core')
0 ignored issues
show
Unused Code introduced by
The parameter $bundle is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

34
    public function getObblmCss(string $entrypoint, /** @scrutinizer ignore-unused */ $bundle = 'core')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
        return $this->packager->getCssEntry($entrypoint);
37
    }
38
39
    public function getObblmJs(string $entrypoint, $bundle = 'core')
0 ignored issues
show
Unused Code introduced by
The parameter $bundle is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getObblmJs(string $entrypoint, /** @scrutinizer ignore-unused */ $bundle = 'core')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        return $this->packager->getJsEntry($entrypoint);
42
    }
43
44
    public function getRosterImageUrl(Rule $rule, string $roster, int $width = null, int $height = 150)
45
    {
46
        return $this->imageHelper->getRosterImage($rule, $roster, $width, $height);
47
    }
48
49
    public function getTeamLogo(Team $team, int $width = 200, int $height = null)
50
    {
51
        return $this->imageHelper->getTeamLogo($team, $width, $height);
52
    }
53
54
    public function getTeamCover(Team $team, int $width = null, int $height = null)
55
    {
56
        return $this->imageHelper->getTeamCover($team, $width, $height);
57
    }
58
}
59