From 155edba00ae0e371e801b0fcf8e95d29d5ff6a65 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Thu, 11 Jun 2015 19:56:51 -0700 Subject: [PATCH 01/14] Add new track type "Other" used by some containers for metadata (like .mov). Also implement explicit Exception type for unknown track types. Optional parameters used to determine if exception is thrown, or unknown tracks are simply skipped (likely preferred). --- src/Container/MediaInfoContainer.php | 32 +++++++++++++++++++-- src/Exception/UnknownTrackTypeException.php | 21 ++++++++++++++ src/Factory/TypeFactory.php | 9 ++++-- src/MediaInfo.php | 4 +-- src/Parser/MediaInfoOutputParser.php | 19 ++++++++++-- src/Type/Other.php | 7 +++++ 6 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 src/Exception/UnknownTrackTypeException.php create mode 100644 src/Type/Other.php diff --git a/src/Container/MediaInfoContainer.php b/src/Container/MediaInfoContainer.php index 52db1af..02c3bd2 100644 --- a/src/Container/MediaInfoContainer.php +++ b/src/Container/MediaInfoContainer.php @@ -8,6 +8,8 @@ use Mhor\MediaInfo\Type\Image; use Mhor\MediaInfo\Type\Subtitle; use Mhor\MediaInfo\Type\Video; +use Mhor\MediaInfo\Type\Other; +use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoContainer { @@ -16,6 +18,7 @@ class MediaInfoContainer const IMAGE_CLASS = 'Mhor\MediaInfo\Type\Image'; const VIDEO_CLASS = 'Mhor\MediaInfo\Type\Video'; const SUBTITLE_CLASS = 'Mhor\MediaInfo\Type\Subtitle'; + const OTHER_CLASS = 'Mhor\MediaInfo\Type\Other'; /** * @var string @@ -47,6 +50,11 @@ class MediaInfoContainer */ private $images = array(); + /** + * @var Other[] + */ + private $others = array(); + /** * @return General */ @@ -71,6 +79,14 @@ public function getImages() return $this->images; } + /** + * @return Other[] + */ + public function getOthers() + { + return $this->others; + } + /** * @param string $version */ @@ -113,7 +129,6 @@ public function setGeneral($general) /** * @param AbstractType $trackType - * @throws \Exception */ public function add(AbstractType $trackType) { @@ -133,8 +148,13 @@ public function add(AbstractType $trackType) case self::SUBTITLE_CLASS: $this->addSubtitle($trackType); break; + case self::OTHER_CLASS: + $this->addOther($trackType); + break; default: - throw new \Exception('Unknow type'); + // skip type type rather than wrecking everything + // unknown track types are already handled in creation, we shouldn't need to throw anything here + break; } } @@ -169,4 +189,12 @@ private function addSubtitle(Subtitle $subtitle) { $this->subtitles[] = $subtitle; } + + /** + * @param Other $other + */ + private function addOther(Other $other) + { + $this->others[] = $other; + } } diff --git a/src/Exception/UnknownTrackTypeException.php b/src/Exception/UnknownTrackTypeException.php new file mode 100644 index 0000000..e2549d9 --- /dev/null +++ b/src/Exception/UnknownTrackTypeException.php @@ -0,0 +1,21 @@ +trackType = $trackType; + } + + public function getTrackType() + { + return $this->trackType; + } +} + +?> diff --git a/src/Factory/TypeFactory.php b/src/Factory/TypeFactory.php index 64c06ed..87b9608 100644 --- a/src/Factory/TypeFactory.php +++ b/src/Factory/TypeFactory.php @@ -8,6 +8,8 @@ use Mhor\MediaInfo\Type\Image; use Mhor\MediaInfo\Type\Subtitle; use Mhor\MediaInfo\Type\Video; +use Mhor\MediaInfo\Type\Other; +use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class TypeFactory { @@ -16,11 +18,12 @@ class TypeFactory const GENERAL = 'General'; const VIDEO = 'Video'; const SUBTITLE = 'Text'; + const OTHER = 'Other'; /** * @param $type * @return AbstractType - * @throws \Exception + * @throws UnknownTrackTypeException */ public function create($type) { @@ -35,8 +38,10 @@ public function create($type) return new Video(); case self::SUBTITLE: return new Subtitle(); + case self::OTHER: + return new Other(); default: - throw new \Exception('Type doesn\'t exist'); + throw new UnknownTrackTypeException($type); } } } diff --git a/src/MediaInfo.php b/src/MediaInfo.php index c50215c..62c3342 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -12,7 +12,7 @@ class MediaInfo * @param $filePath * @return MediaInfoContainer */ - public function getInfo($filePath) + public function getInfo($filePath, $ignoreUnknownTrackTypes = false) { $mediaInfoCommandBuilder = new MediaInfoCommandBuilder(); $output = $mediaInfoCommandBuilder->buildMediaInfoCommandRunner($filePath)->run(); @@ -20,6 +20,6 @@ public function getInfo($filePath) $mediaInfoOutputParser = new MediaInfoOutputParser(); $mediaInfoOutputParser->parse($output); - return $mediaInfoOutputParser->getMediaInfoContainer(); + return $mediaInfoOutputParser->getMediaInfoContainer($ignoreUnknownTrackTypes); } } diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index 3663692..316d47e 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -4,6 +4,7 @@ use Mhor\MediaInfo\Builder\MediaInfoContainerBuilder; use Mhor\MediaInfo\Container\MediaInfoContainer; +use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoOutputParser extends AbstractXmlOutputParser { @@ -24,17 +25,29 @@ public function parse($output) * @throws \Exception * @return MediaInfoContainer */ - public function getMediaInfoContainer() + public function getMediaInfoContainer($ignoreUnknownTrackTypes = false) { if ($this->parsedOutput === null) { throw new \Exception('You must run `parse` before running `getMediaInfoContainer`'); } - $mediaInfoContainerBuilder = new MediaInfoContainerBuilder(); + $mediaInfoContainerBuilder = new MediaInfoContainerBuilder($ignoreUnknownTrackTypes); $mediaInfoContainerBuilder->setVersion($this->parsedOutput['@attributes']['version']); foreach ($this->parsedOutput['File']['track'] as $trackType) { - $mediaInfoContainerBuilder->addTrackType($trackType['@attributes']['type'], $trackType); + try + { + $mediaInfoContainerBuilder->addTrackType($trackType['@attributes']['type'], $trackType); + } + catch (UnknownTrackTypeException $ex) + { + if (!$ignoreUnknownTrackTypes) + { + // rethrow exception + throw $ex; + } + // else ignore + } } return $mediaInfoContainerBuilder->build(); diff --git a/src/Type/Other.php b/src/Type/Other.php new file mode 100644 index 0000000..02ed161 --- /dev/null +++ b/src/Type/Other.php @@ -0,0 +1,7 @@ + Date: Thu, 11 Jun 2015 19:59:52 -0700 Subject: [PATCH 02/14] Actually let this throw exceptions still, it shouldn't be called with an unknown type. --- src/Container/MediaInfoContainer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Container/MediaInfoContainer.php b/src/Container/MediaInfoContainer.php index 02c3bd2..fea2431 100644 --- a/src/Container/MediaInfoContainer.php +++ b/src/Container/MediaInfoContainer.php @@ -152,9 +152,7 @@ public function add(AbstractType $trackType) $this->addOther($trackType); break; default: - // skip type type rather than wrecking everything - // unknown track types are already handled in creation, we shouldn't need to throw anything here - break; + throw new \Exception('Unknown type'); } } From aad876ce916e6da475649bdbe2f4628ccbd31918 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Thu, 11 Jun 2015 20:08:04 -0700 Subject: [PATCH 03/14] Forgot comment. --- src/Container/MediaInfoContainer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Container/MediaInfoContainer.php b/src/Container/MediaInfoContainer.php index fea2431..9ce29f1 100644 --- a/src/Container/MediaInfoContainer.php +++ b/src/Container/MediaInfoContainer.php @@ -129,6 +129,7 @@ public function setGeneral($general) /** * @param AbstractType $trackType + * @throws \Exception */ public function add(AbstractType $trackType) { From f0f5a3d7a88e1812c8eec22a210eb6ad6a351ea5 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Thu, 11 Jun 2015 20:09:51 -0700 Subject: [PATCH 04/14] Proper throws UnknownTrackTypeException docs. --- src/MediaInfo.php | 1 + src/Parser/MediaInfoOutputParser.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MediaInfo.php b/src/MediaInfo.php index 62c3342..975a278 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -10,6 +10,7 @@ class MediaInfo { /** * @param $filePath + * @throws UnknownTrackTypeException * @return MediaInfoContainer */ public function getInfo($filePath, $ignoreUnknownTrackTypes = false) diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index 316d47e..1273f7c 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -22,7 +22,7 @@ public function parse($output) } /** - * @throws \Exception + * @throws UnknownTrackTypeException * @return MediaInfoContainer */ public function getMediaInfoContainer($ignoreUnknownTrackTypes = false) From f49d253f05c5827f6e1307095a00e91b9b06c1a0 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 15:04:26 -0700 Subject: [PATCH 05/14] Travis style fixes. --- src/Exception/UnknownTrackTypeException.php | 4 +--- src/Factory/TypeFactory.php | 14 +++++++------- src/Parser/MediaInfoOutputParser.php | 10 +++------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/Exception/UnknownTrackTypeException.php b/src/Exception/UnknownTrackTypeException.php index e2549d9..4801feb 100644 --- a/src/Exception/UnknownTrackTypeException.php +++ b/src/Exception/UnknownTrackTypeException.php @@ -15,7 +15,5 @@ public function __construct($trackType, $code = 0) public function getTrackType() { return $this->trackType; - } + } } - -?> diff --git a/src/Factory/TypeFactory.php b/src/Factory/TypeFactory.php index 87b9608..d1fd0fc 100644 --- a/src/Factory/TypeFactory.php +++ b/src/Factory/TypeFactory.php @@ -29,19 +29,19 @@ public function create($type) { switch ($type) { case self::AUDIO: - return new Audio(); + return new Audio(); case self::IMAGE: - return new Image(); + return new Image(); case self::GENERAL: - return new General(); + return new General(); case self::VIDEO: - return new Video(); + return new Video(); case self::SUBTITLE: - return new Subtitle(); + return new Subtitle(); case self::OTHER: - return new Other(); + return new Other(); default: - throw new UnknownTrackTypeException($type); + throw new UnknownTrackTypeException($type); } } } diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index 1273f7c..e94f1f0 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -35,14 +35,10 @@ public function getMediaInfoContainer($ignoreUnknownTrackTypes = false) $mediaInfoContainerBuilder->setVersion($this->parsedOutput['@attributes']['version']); foreach ($this->parsedOutput['File']['track'] as $trackType) { - try - { + try { $mediaInfoContainerBuilder->addTrackType($trackType['@attributes']['type'], $trackType); - } - catch (UnknownTrackTypeException $ex) - { - if (!$ignoreUnknownTrackTypes) - { + } catch (UnknownTrackTypeException $ex) { + if (!$ignoreUnknownTrackTypes) { // rethrow exception throw $ex; } From 1504319e91d6c5e9420d7c56c5b40022eeed4c26 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 15:14:03 -0700 Subject: [PATCH 06/14] Really fixed travis styles. --- src/Factory/TypeFactory.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Factory/TypeFactory.php b/src/Factory/TypeFactory.php index d1fd0fc..b6a86aa 100644 --- a/src/Factory/TypeFactory.php +++ b/src/Factory/TypeFactory.php @@ -28,20 +28,20 @@ class TypeFactory public function create($type) { switch ($type) { - case self::AUDIO: - return new Audio(); - case self::IMAGE: - return new Image(); - case self::GENERAL: - return new General(); - case self::VIDEO: - return new Video(); - case self::SUBTITLE: - return new Subtitle(); - case self::OTHER: - return new Other(); - default: - throw new UnknownTrackTypeException($type); + case self::AUDIO: + return new Audio(); + case self::IMAGE: + return new Image(); + case self::GENERAL: + return new General(); + case self::VIDEO: + return new Video(); + case self::SUBTITLE: + return new Subtitle(); + case self::OTHER: + return new Other(); + default: + throw new UnknownTrackTypeException($type); } } } From 7a365e7b2265414bc2a0e88b98919bc4c8054381 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 15:50:33 -0700 Subject: [PATCH 07/14] Added documentation for ignoreUnknownTrackTypes parameters. Also added unit tests for new parameter, and added Output type to normal parsing. --- src/Builder/MediaInfoContainerBuilder.php | 1 + src/MediaInfo.php | 1 + src/Parser/MediaInfoOutputParser.php | 1 + .../Builder/MediaInfoContainerBuilderTest.php | 7 +- test/Parser/MediaInfoOutputParserTest.php | 23 +++ .../mediainfo-output-invalid-types.xml | 136 ++++++++++++++++++ 6 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/mediainfo-output-invalid-types.xml diff --git a/src/Builder/MediaInfoContainerBuilder.php b/src/Builder/MediaInfoContainerBuilder.php index daae8aa..bce2d49 100644 --- a/src/Builder/MediaInfoContainerBuilder.php +++ b/src/Builder/MediaInfoContainerBuilder.php @@ -44,6 +44,7 @@ public function setVersion($version) /** * @param $typeName * @param array $attributes + * @throws UnknownTrackTypeException */ public function addTrackType($typeName, array $attributes) { diff --git a/src/MediaInfo.php b/src/MediaInfo.php index 975a278..059dc02 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -10,6 +10,7 @@ class MediaInfo { /** * @param $filePath + * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. * @throws UnknownTrackTypeException * @return MediaInfoContainer */ diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index e94f1f0..592ec07 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -22,6 +22,7 @@ public function parse($output) } /** + * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. * @throws UnknownTrackTypeException * @return MediaInfoContainer */ diff --git a/test/Builder/MediaInfoContainerBuilderTest.php b/test/Builder/MediaInfoContainerBuilderTest.php index e21be01..53f986b 100644 --- a/test/Builder/MediaInfoContainerBuilderTest.php +++ b/test/Builder/MediaInfoContainerBuilderTest.php @@ -50,10 +50,15 @@ public function testAddTrackType() $mediaContainer = $mediaInfoContainerBuilder->build(); $subtitles = $mediaContainer->getSubtitles(); $this->assertEquals(0, count($subtitles[0]->get())); + + $mediaInfoContainerBuilder->addTrackType(TypeFactory::OTHER, array()); + $mediaContainer = $mediaInfoContainerBuilder->build(); + $others = $mediaContainer->getOthers(); + $this->assertEquals(0, count($others[0]->get())); } /** - * @expectedException \Exception + * @expectedException UnknownTrackTypeException */ public function testAddInvalidType() { diff --git a/test/Parser/MediaInfoOutputParserTest.php b/test/Parser/MediaInfoOutputParserTest.php index 9d68eed..0bca8be 100644 --- a/test/Parser/MediaInfoOutputParserTest.php +++ b/test/Parser/MediaInfoOutputParserTest.php @@ -11,9 +11,12 @@ class MediaInfoOutputParserTest extends \PHPUnit_Framework_TestCase */ private $outputPath; + private $invalidOutputPath; + public function setUp() { $this->outputPath = __DIR__.'/../fixtures/mediainfo-output.xml'; + $this->invalidOutputPath = __DIR__.'/../fixtures/mediainfo-output-invalid-types.xml'; } /** @@ -48,4 +51,24 @@ public function testGetMediaInfoContainer() $subtitles = $mediaInfoContainer->getSubtitles(); $this->assertEquals(16, count($subtitles[0]->get())); } + + public function testIgnoreInvalidTrackType() + { + $mediaInfoOutputParser = new MediaInfoOutputParser(); + $mediaInfoOutputParser->parse(file_get_contents($this->invalidOutputPath)); + // the xml specifically has an unknown type in it + // when passing true we want to ignore/skip unknown track types + $mediaInfoContainer = $mediaInfoOutputParser->getMediaInfoContainer(true); + } + + /** + * @expectedException UnknownTrackTypeException + */ + public function testThrowInvalidTrackType() + { + $mediaInfoOutputParser = new MediaInfoOutputParser(); + $mediaInfoOutputParser->parse(file_get_contents($this->invalidOutputPath)); + // will throw exception here as default behavior + $mediaInfoContainer = $mediaInfoOutputParser->getMediaInfoContainer(); + } } diff --git a/test/fixtures/mediainfo-output-invalid-types.xml b/test/fixtures/mediainfo-output-invalid-types.xml new file mode 100644 index 0000000..1f102e9 --- /dev/null +++ b/test/fixtures/mediainfo-output-invalid-types.xml @@ -0,0 +1,136 @@ + + + + + 284 + 1 + General + General + 0 + 1 + MPEG Audio + MPEG Audio + MPEG-1 Audio layer 3 + test.mp3 + test.mp3 + mp3 + MPEG Audio + MPEG Audio + m1a mpa1 mp1 m2a mpa2 mp2 mp3 + MPEG Audio + audio/mpeg + MPEG Audio + MPEG Audio + m1a mpa1 mp1 m2a mpa2 mp2 mp3 + 19316079 + 18.4 MiB + 18 MiB + 18 MiB + 18.4 MiB + 18.42 MiB + 475193 + 7mn 55s + 7mn 55s 193ms + 7mn 55s + 00:07:55.193 + CBR + Constant + 320000 + 320 Kbps + 308340 + 301 KiB (2%) + 301 KiB + 301 KiB + 301 KiB + 301.1 KiB + 301 KiB (2%) + 0.01596 + Track Title + Album Title + Various Artists + Track Title + 2 + 2 + Track Artist + 2014 + sample_binary_cover + UTC 2014-12-06 16:43:30 + 2014-12-06 17:43:30 + + + + 222 + 1 + Audio + Audio + 0 + MPEG Audio + MPEG Audio + Version 1 + Layer 3 + audio/mpeg + MPA1L3 + MPEG-1 Audio layer 3 + 475611 + 7mn 55s + 7mn 55s 611ms + 7mn 55s + 00:07:55.611 + CBR + Constant + 320000 + 320 Kbps + 2 + 2 channels + 44100 + 44.1 KHz + 20974464 + 18207 + Lossy + Lossy + 19007739 + 18.1 MiB (98%) + 18 MiB + 18 MiB + 18.1 MiB + 18.13 MiB + 18.1 MiB (98%) + 0.98404 + + + 195 + 8 + Text + Text + 6 + 7 + 9 + 11 + 11 + 652628868 + UTF-8 + UTF-8 + S_TEXT/UTF8 + UTF-8 Plain Text + S_TEXT/UTF8 + UTF-8 + UTF-8 Plain Text + ja + Japanese + Japanese + ja + jpn + ja + No + No + No + No + + + + + 1 + test + + + From 86d89a8df8c76bcbcba9ab8d8ef0a31b871da476 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 15:53:12 -0700 Subject: [PATCH 08/14] Y u so mean to me phpcbf. --- src/Factory/TypeFactory.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Factory/TypeFactory.php b/src/Factory/TypeFactory.php index b6a86aa..1910608 100644 --- a/src/Factory/TypeFactory.php +++ b/src/Factory/TypeFactory.php @@ -29,19 +29,19 @@ public function create($type) { switch ($type) { case self::AUDIO: - return new Audio(); + return new Audio(); case self::IMAGE: - return new Image(); + return new Image(); case self::GENERAL: - return new General(); + return new General(); case self::VIDEO: - return new Video(); + return new Video(); case self::SUBTITLE: - return new Subtitle(); + return new Subtitle(); case self::OTHER: - return new Other(); + return new Other(); default: - throw new UnknownTrackTypeException($type); + throw new UnknownTrackTypeException($type); } } } From 2afdb23ad26bae6716684a263dc806c608033f56 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 16:02:26 -0700 Subject: [PATCH 09/14] Forgot using statements for exceptions. --- src/Builder/MediaInfoContainerBuilder.php | 1 + test/Builder/MediaInfoContainerBuilderTest.php | 1 + test/Parser/MediaInfoOutputParserTest.php | 1 + 3 files changed, 3 insertions(+) diff --git a/src/Builder/MediaInfoContainerBuilder.php b/src/Builder/MediaInfoContainerBuilder.php index bce2d49..aca9db6 100644 --- a/src/Builder/MediaInfoContainerBuilder.php +++ b/src/Builder/MediaInfoContainerBuilder.php @@ -6,6 +6,7 @@ use Mhor\MediaInfo\Factory\AttributeFactory; use Mhor\MediaInfo\Factory\TypeFactory; use Mhor\MediaInfo\Type\AbstractType; +use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoContainerBuilder { diff --git a/test/Builder/MediaInfoContainerBuilderTest.php b/test/Builder/MediaInfoContainerBuilderTest.php index 53f986b..08e8a90 100644 --- a/test/Builder/MediaInfoContainerBuilderTest.php +++ b/test/Builder/MediaInfoContainerBuilderTest.php @@ -5,6 +5,7 @@ use Mhor\MediaInfo\Builder\MediaInfoContainerBuilder; use Mhor\MediaInfo\Factory\TypeFactory; use Mhor\MediaInfo\Type\AbstractType; +use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class TrackTestType extends AbstractType{} diff --git a/test/Parser/MediaInfoOutputParserTest.php b/test/Parser/MediaInfoOutputParserTest.php index 0bca8be..4d60224 100644 --- a/test/Parser/MediaInfoOutputParserTest.php +++ b/test/Parser/MediaInfoOutputParserTest.php @@ -3,6 +3,7 @@ namespace Mhor\MediaInfo\Test\Parser; use Mhor\MediaInfo\Parser\MediaInfoOutputParser; +use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoOutputParserTest extends \PHPUnit_Framework_TestCase { From ed404259b0c348f87f18c8a186a969469d550f6f Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 16:03:13 -0700 Subject: [PATCH 10/14] I'm not sure what this thing wants...phpcbf isn't fixing the style. --- src/Factory/TypeFactory.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Factory/TypeFactory.php b/src/Factory/TypeFactory.php index 1910608..ff48827 100644 --- a/src/Factory/TypeFactory.php +++ b/src/Factory/TypeFactory.php @@ -28,20 +28,20 @@ class TypeFactory public function create($type) { switch ($type) { - case self::AUDIO: - return new Audio(); - case self::IMAGE: - return new Image(); - case self::GENERAL: - return new General(); - case self::VIDEO: - return new Video(); - case self::SUBTITLE: - return new Subtitle(); - case self::OTHER: - return new Other(); - default: - throw new UnknownTrackTypeException($type); + case self::AUDIO: + return new Audio(); + case self::IMAGE: + return new Image(); + case self::GENERAL: + return new General(); + case self::VIDEO: + return new Video(); + case self::SUBTITLE: + return new Subtitle(); + case self::OTHER: + return new Other(); + default: + throw new UnknownTrackTypeException($type); } } } From faf3ea8f05c95187f5be82f3069aa7a4cc2a61cf Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 16:14:06 -0700 Subject: [PATCH 11/14] Grr, documentation scope?! --- test/Builder/MediaInfoContainerBuilderTest.php | 3 +-- test/Parser/MediaInfoOutputParserTest.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/Builder/MediaInfoContainerBuilderTest.php b/test/Builder/MediaInfoContainerBuilderTest.php index 08e8a90..e79eb34 100644 --- a/test/Builder/MediaInfoContainerBuilderTest.php +++ b/test/Builder/MediaInfoContainerBuilderTest.php @@ -5,7 +5,6 @@ use Mhor\MediaInfo\Builder\MediaInfoContainerBuilder; use Mhor\MediaInfo\Factory\TypeFactory; use Mhor\MediaInfo\Type\AbstractType; -use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class TrackTestType extends AbstractType{} @@ -59,7 +58,7 @@ public function testAddTrackType() } /** - * @expectedException UnknownTrackTypeException + * @expectedException Mhor\MediaInfo\Exception\UnknownTrackTypeException */ public function testAddInvalidType() { diff --git a/test/Parser/MediaInfoOutputParserTest.php b/test/Parser/MediaInfoOutputParserTest.php index 4d60224..8f6f56e 100644 --- a/test/Parser/MediaInfoOutputParserTest.php +++ b/test/Parser/MediaInfoOutputParserTest.php @@ -3,7 +3,6 @@ namespace Mhor\MediaInfo\Test\Parser; use Mhor\MediaInfo\Parser\MediaInfoOutputParser; -use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoOutputParserTest extends \PHPUnit_Framework_TestCase { @@ -63,7 +62,7 @@ public function testIgnoreInvalidTrackType() } /** - * @expectedException UnknownTrackTypeException + * @expectedException Mhor\MediaInfo\Exception\UnknownTrackTypeException */ public function testThrowInvalidTrackType() { From fec11839df69f63a4235b7c2839ccdc9c6735b3f Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 16:16:50 -0700 Subject: [PATCH 12/14] Documentation line length fix. --- src/MediaInfo.php | 3 ++- src/Parser/MediaInfoOutputParser.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MediaInfo.php b/src/MediaInfo.php index 059dc02..f611c2a 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -10,7 +10,8 @@ class MediaInfo { /** * @param $filePath - * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. + * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The + default behavior (false) is throw an exception on unknown track types. * @throws UnknownTrackTypeException * @return MediaInfoContainer */ diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index 592ec07..a037933 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -22,7 +22,8 @@ public function parse($output) } /** - * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. + * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The + default behavior (false) is throw an exception on unknown track types. * @throws UnknownTrackTypeException * @return MediaInfoContainer */ From e53327d5280443809b956935a8337e6fe7aa4aef Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 16:23:44 -0700 Subject: [PATCH 13/14] Whitespace --- src/MediaInfo.php | 2 +- src/Parser/MediaInfoOutputParser.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MediaInfo.php b/src/MediaInfo.php index f611c2a..39a9653 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -10,7 +10,7 @@ class MediaInfo { /** * @param $filePath - * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The + * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. * @throws UnknownTrackTypeException * @return MediaInfoContainer diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index a037933..6a9576c 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -22,7 +22,7 @@ public function parse($output) } /** - * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The + * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. * @throws UnknownTrackTypeException * @return MediaInfoContainer From f25a30324cbc8de86755b5445be38d8abd3ff471 Mon Sep 17 00:00:00 2001 From: Nicholi Date: Fri, 12 Jun 2015 16:41:17 -0700 Subject: [PATCH 14/14] Consistently use full namespace for UnknownTrackTypeException in docs. --- src/Builder/MediaInfoContainerBuilder.php | 3 +-- src/Container/MediaInfoContainer.php | 1 - src/Factory/TypeFactory.php | 2 +- src/MediaInfo.php | 2 +- src/Parser/MediaInfoOutputParser.php | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Builder/MediaInfoContainerBuilder.php b/src/Builder/MediaInfoContainerBuilder.php index aca9db6..01e5f20 100644 --- a/src/Builder/MediaInfoContainerBuilder.php +++ b/src/Builder/MediaInfoContainerBuilder.php @@ -6,7 +6,6 @@ use Mhor\MediaInfo\Factory\AttributeFactory; use Mhor\MediaInfo\Factory\TypeFactory; use Mhor\MediaInfo\Type\AbstractType; -use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoContainerBuilder { @@ -45,7 +44,7 @@ public function setVersion($version) /** * @param $typeName * @param array $attributes - * @throws UnknownTrackTypeException + * @throws Mhor\MediaInfo\Exception\UnknownTrackTypeException */ public function addTrackType($typeName, array $attributes) { diff --git a/src/Container/MediaInfoContainer.php b/src/Container/MediaInfoContainer.php index 9ce29f1..b9f589a 100644 --- a/src/Container/MediaInfoContainer.php +++ b/src/Container/MediaInfoContainer.php @@ -9,7 +9,6 @@ use Mhor\MediaInfo\Type\Subtitle; use Mhor\MediaInfo\Type\Video; use Mhor\MediaInfo\Type\Other; -use Mhor\MediaInfo\Exception\UnknownTrackTypeException; class MediaInfoContainer { diff --git a/src/Factory/TypeFactory.php b/src/Factory/TypeFactory.php index ff48827..0d993bd 100644 --- a/src/Factory/TypeFactory.php +++ b/src/Factory/TypeFactory.php @@ -23,7 +23,7 @@ class TypeFactory /** * @param $type * @return AbstractType - * @throws UnknownTrackTypeException + * @throws Mhor\MediaInfo\Exception\UnknownTrackTypeException */ public function create($type) { diff --git a/src/MediaInfo.php b/src/MediaInfo.php index 39a9653..7a9c436 100644 --- a/src/MediaInfo.php +++ b/src/MediaInfo.php @@ -12,7 +12,7 @@ class MediaInfo * @param $filePath * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. - * @throws UnknownTrackTypeException + * @throws Mhor\MediaInfo\Exception\UnknownTrackTypeException * @return MediaInfoContainer */ public function getInfo($filePath, $ignoreUnknownTrackTypes = false) diff --git a/src/Parser/MediaInfoOutputParser.php b/src/Parser/MediaInfoOutputParser.php index 6a9576c..154a614 100644 --- a/src/Parser/MediaInfoOutputParser.php +++ b/src/Parser/MediaInfoOutputParser.php @@ -24,7 +24,7 @@ public function parse($output) /** * @param bool $ignoreUnknownTrackTypes Optional parameter used to skip unknown track types by passing true. The default behavior (false) is throw an exception on unknown track types. - * @throws UnknownTrackTypeException + * @throws Mhor\MediaInfo\Exception\UnknownTrackTypeException * @return MediaInfoContainer */ public function getMediaInfoContainer($ignoreUnknownTrackTypes = false)