diff --git a/src/Tag/ExtInf.php b/src/Tag/ExtInf.php index d141ec9..4ef56b2 100644 --- a/src/Tag/ExtInf.php +++ b/src/Tag/ExtInf.php @@ -29,7 +29,9 @@ public function __construct(?string $lineStr = null) public function __toString(): string { - return '#EXTINF:'.$this->getDuration().' '.$this->getAttributesString().', '.$this->getTitle(); + $attributesString = $this->getAttributesString(); + + return '#EXTINF:'.$this->getDuration().('' === $attributesString ? '' : ' '.$attributesString).','.$this->getTitle(); } /** diff --git a/tests/M3uDataTest.php b/tests/M3uDataTest.php index 852c6a4..2a9724f 100644 --- a/tests/M3uDataTest.php +++ b/tests/M3uDataTest.php @@ -14,7 +14,7 @@ class M3uDataTest extends TestCase public function testComplexDefaultEntryToString(): void { $expectedString = '#EXTM3U test-name="test-value"'."\n"; - $expectedString .= '#EXTINF:123 test-attr="test-attrname", extinf-title'."\n"; + $expectedString .= '#EXTINF:123 test-attr="test-attrname",extinf-title'."\n"; $expectedString .= '#EXTTV:hd,sd;ru;xml-tv-id;https://example.org/icon.png'."\n"; $expectedString .= '#EXTLOGO:https://example.org/logo.png'."\n"; $expectedString .= 'test-path'; @@ -52,11 +52,11 @@ public function testComplexDefaultEntryToString(): void public function testComplexDefaultEntriesToString(): void { $expectedString = '#EXTM3U test-name="test-value"'."\n"; - $expectedString .= '#EXTINF:123 test-attr="test-attrname1", extinf-title1'."\n"; + $expectedString .= '#EXTINF:123 test-attr="test-attrname1",extinf-title1'."\n"; $expectedString .= '#EXTTV:hd,sd;ru;xml-tv-id;https://example.org/icon.png'."\n"; $expectedString .= '#EXTLOGO:https://example.org/logo.png'."\n"; $expectedString .= 'test-path1'."\n"; - $expectedString .= '#EXTINF:123 test-attr="test-attrname2", extinf-title2'."\n"; + $expectedString .= '#EXTINF:123 test-attr="test-attrname2",extinf-title2'."\n"; $expectedString .= '#EXTTV:hd,sd;ru;xml-tv-id;https://example.org/icon.png'."\n"; $expectedString .= '#EXTLOGO:https://example.org/logo.png'."\n"; $expectedString .= 'test-path2'; diff --git a/tests/Tag/ExtInfTest.php b/tests/Tag/ExtInfTest.php index 407c168..68e4d67 100644 --- a/tests/Tag/ExtInfTest.php +++ b/tests/Tag/ExtInfTest.php @@ -128,7 +128,7 @@ public function testParseExtInf(): void public function testGenerateExtInf(): void { $expectedString = '#EXTM3U'."\n"; - $expectedString .= '#EXTINF:123 test-attr="test-attrname", extinf-title'."\n"; + $expectedString .= '#EXTINF:123 test-attr="test-attrname",extinf-title'."\n"; $expectedString .= 'test-path'; $entry = new M3uEntry();