diff --git a/src/Code/Converters/SmiConverter.php b/src/Code/Converters/SmiConverter.php index bbedd5f..0b92259 100644 --- a/src/Code/Converters/SmiConverter.php +++ b/src/Code/Converters/SmiConverter.php @@ -93,7 +93,7 @@ public function fileContentToInternalFormat($file_content, $original_file_conten $i++; } } - if (!isset($internal_format[$i - 1]['end'])) { + if (isset($internal_format[$i - 1]['start']) && !isset($internal_format[$i - 1]['end'])) { $internal_format[$i - 1]['end'] = $internal_format[$i - 1]['start'] + 1; } diff --git a/tests/formats/SmiTest.php b/tests/formats/SmiTest.php index e8c129f..a6eb624 100644 --- a/tests/formats/SmiTest.php +++ b/tests/formats/SmiTest.php @@ -4,6 +4,7 @@ use Done\Subtitles\Code\Converters\SmiConverter; use Done\Subtitles\Code\Helpers; +use Done\Subtitles\Code\UserException; use Done\Subtitles\Subtitles; use PHPUnit\Framework\TestCase; use Helpers\AdditionalAssertionsTrait; @@ -192,6 +193,28 @@ public function testNonEnglishWords() $this->assertInternalFormatsEqual($expected, $actual); } + public function testNoTextDoesntThrowPhpException() + { + $this->expectException(UserException::class); + + $actual = Subtitles::loadFromString(' + + + + + +

  +

  +

  + + + ')->getInternalFormat(); + } + // ---------------------------------- private ---------------------------------------------------------------------- private static function fileContent()