diff --git a/src/Builder/MediaInfoCommandBuilder.php b/src/Builder/MediaInfoCommandBuilder.php index 274131f..9c9f6d4 100644 --- a/src/Builder/MediaInfoCommandBuilder.php +++ b/src/Builder/MediaInfoCommandBuilder.php @@ -15,14 +15,16 @@ class MediaInfoCommandBuilder */ public function buildMediaInfoCommandRunner($filepath, array $configuration = array()) { - $fileSystem = new Filesystem(); + if (filter_var($filepath, FILTER_VALIDATE_URL) === false) { + $fileSystem = new Filesystem(); - if (!$fileSystem->exists($filepath)) { - throw new \Exception('File doesn\'t exist'); - } + if (!$fileSystem->exists($filepath)) { + throw new \Exception('File doesn\'t exist'); + } - if (is_dir($filepath)) { - throw new \Exception('You must specify a filename, not a directory name'); + if (is_dir($filepath)) { + throw new \Exception('You must specify a filename, not a directory name'); + } } $configuration = $configuration + array( diff --git a/test/Builder/MediaInfoCommandBuilderTest.php b/test/Builder/MediaInfoCommandBuilderTest.php index be8184a..ee8ddff 100644 --- a/test/Builder/MediaInfoCommandBuilderTest.php +++ b/test/Builder/MediaInfoCommandBuilderTest.php @@ -14,6 +14,21 @@ public function setUp() $this->filePath = __DIR__.'/../fixtures/test.mp3'; } + public function testBuilderCommandWithUrl() + { + $mediaInfoCommandBuilder = new MediaInfoCommandBuilder(); + $mediaInfoCommandRunner = $mediaInfoCommandBuilder->buildMediaInfoCommandRunner('https://example.org/'); + + $equalsMediaInfoCommandRunner = new MediaInfoCommandRunner('https://example.org/'); + $this->assertEquals($equalsMediaInfoCommandRunner, $mediaInfoCommandRunner); + + $mediaInfoCommandBuilder = new MediaInfoCommandBuilder(); + $mediaInfoCommandRunner = $mediaInfoCommandBuilder->buildMediaInfoCommandRunner('http://example.org/'); + + $equalsMediaInfoCommandRunner = new MediaInfoCommandRunner('http://example.org/'); + $this->assertEquals($equalsMediaInfoCommandRunner, $mediaInfoCommandRunner); + } + /** * @expectedException \Exception */