Skip to content

Commit

Permalink
fix: better compatibility with https://datatracker.ietf.org/doc/html/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Jul 28, 2021
1 parent b359006 commit 17f31eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Tag/ExtInf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/M3uDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion tests/Tag/ExtInfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 17f31eb

Please sign in to comment.