MediaExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 32
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A getFilters() 0 6 1
A generateMediaUrl() 0 4 1
A getFunctions() 0 4 1
1
<?php
2
3
namespace Alpixel\Bundle\MediaBundle\Twig\Extension;
4
5
use Alpixel\Bundle\MediaBundle\Entity\Media;
6
use Alpixel\Bundle\MediaBundle\Services\MediaManager;
7
8
class MediaExtension extends \Twig_Extension
9
{
10
    protected $mediaManager;
11
12
    public function __construct(MediaManager $mm)
13
    {
14
        $this->mediaManager = $mm;
15
    }
16
17
    public function getName()
18
    {
19
        return 'alpixel_media';
20
    }
21
22
    public function getFunctions()
23
    {
24
        return [];
25
    }
26
27
    public function getFilters()
28
    {
29
        return [
30
            new \Twig_SimpleFilter('media_url', [$this, 'generateMediaUrl']),
31
        ];
32
    }
33
34
    public function generateMediaUrl(Media $media, $options = [])
35
    {
36
        return $this->mediaManager->generateUrl($media, $options);
37
    }
38
39
}
40