Passed
Branch master (b4f9b9)
by Maxime
03:00
created

MediaInfoCommandBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 0
cbo 2
dl 0
loc 27
ccs 8
cts 9
cp 0.8889
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildMediaInfoCommandRunner() 0 18 3
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 3
    public function buildMediaInfoCommandRunner($filepath, array $configuration = array())
17
    {
18 3
        $fileSystem = new Filesystem();
19
20 3
        if (!$fileSystem->exists($filepath)) {
21 1
            throw new \Exception('File doesn\'t exist');
22
        }
23
24 2
        if (is_dir($filepath)) {
25
            throw new \Exception('You must specify a filename, not a directory name');
26
        }
27
28
        $configuration = $configuration + array(
29 2
            'command' => null,
30 2
        );
31
32 2
        return new MediaInfoCommandRunner($filepath, $configuration['command']);
33
    }
34
}
35