Completed
Push — 5.6 ( 679697...f4d50c )
by Jeroen
16:35 queued 10:49
created

AbstractMediaHandler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 91
ccs 5
cts 11
cp 0.4545
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPriority() 0 4 1
A getFormTypeOptions() 0 4 1
getName() 0 1 ?
getType() 0 1 ?
getFormType() 0 1 ?
canHandle() 0 1 ?
getFormHelper() 0 1 ?
prepareMedia() 0 1 ?
saveMedia() 0 1 ?
updateMedia() 0 1 ?
removeMedia() 0 1 ?
createNew() 0 1 ?
getAddFolderActions() 0 1 ?
A getShowTemplate() 0 4 1
A getImageUrl() 0 4 1
1
<?php
2
3
namespace Kunstmaan\MediaBundle\Helper\Media;
4
5
use Kunstmaan\MediaBundle\Entity\Media;
6
7
abstract class AbstractMediaHandler
8
{
9
    private $priority;
10
11
    /**
12
     * @param int $priority
13
     */
14 21
    public function __construct($priority = 0)
15
    {
16 21
        $this->priority = $priority;
17 21
    }
18
19
    /**
20
     * @return int
21
     */
22 7
    public function getPriority()
23
    {
24 7
        return $this->priority;
25
    }
26
27
    /**
28
     * Return the default form type options
29
     *
30
     * @return array
31
     */
32
    public function getFormTypeOptions()
33
    {
34
        return [];
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    abstract public function getName();
41
42
    /**
43
     * @return string
44
     */
45
    abstract public function getType();
46
47
    /**
48
     * @return string
49
     */
50
    abstract public function getFormType();
51
52
    /**
53
     * @param mixed $media
54
     */
55
    abstract public function canHandle($media);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
56
57
    /**
58
     * @return mixed
59
     */
60
    abstract public function getFormHelper(Media $media);
61
62
    abstract public function prepareMedia(Media $media);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
63
64
    abstract public function saveMedia(Media $media);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
65
66
    abstract public function updateMedia(Media $media);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
67
68
    abstract public function removeMedia(Media $media);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
69
70
    /**
71
     * @param mixed $data
72
     *
73
     * @return Media
74
     */
75
    abstract public function createNew($data);
76
77
    public function getShowTemplate(Media $media)
78
    {
79
        return '@KunstmaanMedia/Media/show.html.twig';
80
    }
81
82
    /**
83
     * @param Media  $media    The media entity
84
     * @param string $basepath The base path
85
     *
86
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
87
     */
88
    public function getImageUrl(Media $media, $basepath)
89
    {
90
        return null;
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    abstract public function getAddFolderActions();
97
}
98