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

Type::getMimeType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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