Completed
Push — master ( 6ea9b4...222850 )
by Andreas
04:32
created

Type   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 54
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getExtensions() 0 4 1
A getPreferredExtension() 0 4 1
A getMimeType() 0 4 1
1
<?php
2
/**
3
 * Represents a file type.
4
 *
5
 * @copyright 2018 Institute of Legal Medicine, Medical University of Innsbruck
6
 * @author Andreas Erhard <[email protected]>
7
 * @license LGPL-3.0-only
8
 * @link http://www.gerichtsmedizin.at/
9
 *
10
 * @package fileinfo
11
 */
12
namespace Gmi\Toolkit\Fileinfo\Type;
13
14
/**
15
 * Represents a file type with (possible) extensions and a MIME type.
16
 */
17
class Type
18
{
19
    /**
20
     * @var string[]
21
     */
22
    private $extensions;
23
24
    /**
25
     * @var string
26
     */
27
    private $mimeType;
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param string[] $extensions
33
     * @param string   $mimeType
34
     */
35 10
    public function __construct(array $extensions, $mimeType)
36
    {
37 10
        $this->extensions = $extensions;
38 10
        $this->mimeType = $mimeType;
39 10
    }
40
41
    /**
42
     * Returns the file extensions for the file type.
43
     *
44
     * @return string[]
45
     */
46 7
    public function getExtensions()
47
    {
48 7
        return $this->extensions;
49
    }
50
51
    /**
52
     * Returns the preferred file extension for the file type.
53
     *
54
     * @return string
55
     */
56 1
    public function getPreferredExtension()
57
    {
58 1
        return $this->extensions[0];
59
    }
60
61
    /**
62
     * Returns the MIME type for the file type.
63
     *
64
     * @return string
65
     */
66 7
    public function getMimeType()
67
    {
68 7
        return $this->mimeType;
69
    }
70
}
71