Passed
Push — master ( 2ddebf...84c74c )
by Petr
09:17 queued 01:35
created

LocalVolume2   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hasDependencies() 0 3 2
A getMime() 0 9 2
1
<?php
2
3
namespace kalanis\kw_mime\Check;
4
5
6
use kalanis\kw_mime\MimeException;
7
use kalanis\kw_paths\PathsException;
8
9
10
/**
11
 * Class LocalVolume2
12
 * @package kalanis\kw_mime\Check
13
 * System library to detect the mime type on local volume
14
 */
15
class LocalVolume2 extends ALocalVolume
16
{
17 3
    protected function hasDependencies(): bool
18
    {
19 3
        return $this->isMimeClass() && $this->isMimeMethod();
20
    }
21
22 3
    public function getMime(array $path): string
23
    {
24 3
        $this->checkMimeClass();
25 3
        $this->checkMimeFunction();
26
        try {
27 3
            $fileinfo = new \finfo(\FILEINFO_MIME); // file mimetype
28 3
            return $this->determineResult($fileinfo->buffer($this->pathOnVolume($path)));
29 1
        } catch (PathsException $ex) {
30 1
            throw new MimeException($ex->getMessage(), $ex->getCode(), $ex);
31
        }
32
    }
33
}
34