Completed
Push — master ( a17f5b...d39ab0 )
by Maxime
02:11
created

MediaInfoCommandBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 4
c 5
b 0
f 0
lcom 0
cbo 2
dl 0
loc 29
ccs 10
cts 11
cp 0.9091
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildMediaInfoCommandRunner() 0 20 4
1
<?php
2
3
namespace Mhor\MediaInfo\Builder;
4
5
use Mhor\MediaInfo\Runner\MediaInfoCommandRunner;
6
use Symfony\Component\Filesystem\Filesystem;
7
8
class MediaInfoCommandBuilder
9
{
10
    /**
11
     * @param string $filepath
12
     * @param array  $configuration
13
     *
14
     * @return MediaInfoCommandRunner
15
     */
16 4
    public function buildMediaInfoCommandRunner($filepath, array $configuration = array())
17
    {
18 4
        if (filter_var($filepath, FILTER_VALIDATE_URL) === false) {
19 3
            $fileSystem = new Filesystem();
20
21 3
            if (!$fileSystem->exists($filepath)) {
22 1
                throw new \Exception('File doesn\'t exist');
23
            }
24
25 2
            if (is_dir($filepath)) {
26
                throw new \Exception('You must specify a filename, not a directory name');
27
            }
28 2
        }
29
30
        $configuration = $configuration + array(
31 3
            'command' => null,
32 3
        );
33
34 3
        return new MediaInfoCommandRunner($filepath, $configuration['command']);
35
    }
36
}
37