Test Setup Failed
Push — master ( 9913af...f4220c )
by Chauncey
13:04
created

VideoProperty   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 4 1
A getDefaultAcceptedMimetypes() 0 10 1
A resolveExtensionFromMimeType() 0 19 6
1
<?php
2
3
namespace Charcoal\Property;
4
5
// From 'charcoal-property'
6
use Charcoal\Property\FileProperty;
7
8
/**
9
 * Video Property.
10
 *
11
 * The video property is a specialized file property that handles video file.
12
 */
13
class VideoProperty extends FileProperty
14
{
15
    /**
16
     * @return string
17
     */
18
    public function type()
19
    {
20
        return 'video';
21
    }
22
23
    /**
24
     * Retrieves the default list of acceptable MIME types for uploaded files.
25
     *
26
     * This method should be overriden.
27
     *
28
     * @return string[]
29
     */
30
    public function getDefaultAcceptedMimetypes()
31
    {
32
        return [
33
            'video/mp4',
34
            'video/webm',
35
            'video/ogg',
36
            'video/ogv',
37
            'video/x-matroska',
38
        ];
39
    }
40
41
    /**
42
     * Resolve the file extension from the given MIME type.
43
     *
44
     * @param  string $type The MIME type to resolve.
45
     * @return string|null The extension based on the MIME type.
46
     */
47
    protected function resolveExtensionFromMimeType($type)
48
    {
49
        switch ($type) {
50
            case 'video/mp4':
51
                return 'mp4';
52
53
            case 'video/webm':
54
                return 'webm';
55
56
            case 'video/ogg':
57
            case 'video/ogv':
58
                return 'ogv';
59
60
            case 'video/x-matroska':
61
                return 'mkv';
62
        }
63
64
        return null;
65
    }
66
}
67