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

LocalVolume2::hasDependencies()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

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