Completed
Push — master ( 61e1ff...22d949 )
by
unknown
03:51
created

ImageProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 52
ccs 0
cts 28
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A buildProviderCreateForm() 0 4 1
A update() 0 9 2
A getIcon() 0 4 1
A getTitle() 0 4 1
A getType() 0 4 1
A getMediaTemplate() 0 4 1
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Provider;
4
5
use MediaMonks\SonataMediaBundle\Entity\Media;
6
use Sonata\AdminBundle\Form\FormMapper;
7
use Symfony\Component\Validator\Constraints as Constraint;
8
9
class ImageProvider extends AbstractProvider
10
{
11
    /**
12
     * @param FormMapper $formMapper
13
     */
14
    public function buildProviderCreateForm(FormMapper $formMapper)
15
    {
16
        $this->addFileUploadField($formMapper, 'binaryContent', 'Image');
17
    }
18
19
    /**
20
     * @param Media $media
21
     */
22
    public function update(Media $media)
23
    {
24
        if (!is_null($media->getBinaryContent())) {
25
            $filename = $this->handleFileUpload($media, true);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $filename is correct as $this->handleFileUpload($media, true) (which targets MediaMonks\SonataMediaBu...der::handleFileUpload()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
26
            $media->setProviderReference($filename);
27
        }
28
29
        parent::update($media);
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getIcon()
36
    {
37
        return 'photo';
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getTitle()
44
    {
45
        return 'Image';
46
    }
47
48
    public function getType()
49
    {
50
        return 'image';
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getMediaTemplate()
57
    {
58
        return 'MediaMonksSonataMediaBundle:Provider:image_media.html.twig';
59
    }
60
}
61