Skip to content

Commit

Permalink
Merge pull request #56 from mhor/feature-use-url-as-filepath
Browse files Browse the repository at this point in the history
Use url as file path close #55
  • Loading branch information
mhor committed May 22, 2016
2 parents a17f5b0 + 71a3559 commit d39ab01
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Builder/MediaInfoCommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 15 additions & 0 deletions test/Builder/MediaInfoCommandBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit d39ab01

Please sign in to comment.