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

ImageProvider::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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