diff --git a/src/Drivers/AbstractDecoder.php b/src/Drivers/AbstractDecoder.php index 9550de96..7e72e4ee 100644 --- a/src/Drivers/AbstractDecoder.php +++ b/src/Drivers/AbstractDecoder.php @@ -156,15 +156,6 @@ abstract class AbstractDecoder extends DriverSpecialized implements DecoderInter return !empty($this->mediaType()); } - public function parameters(): array - { - if (isset($this->matches['parameters']) && !empty($this->matches['parameters'])) { - return explode(';', trim($this->matches['parameters'], ';')); - } - - return []; - } - public function isBase64Encoded(): bool { if (isset($this->matches['base64']) && $this->matches['base64'] === ';base64') { diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 76863af7..9bff60b9 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -138,6 +138,13 @@ class CollectionTest extends TestCase $this->assertEquals('default', $collection->getAtPosition(3, 'default')); } + public function testGetAtPositionEmpty(): void + { + $collection = new Collection(); + $this->assertNull($collection->getAtPosition()); + $this->assertEquals('default', $collection->getAtPosition(3, 'default')); + } + public function testEmpty(): void { $collection = new Collection([1, 2, 3]); diff --git a/tests/Drivers/AbstractDecoderTest.php b/tests/Drivers/AbstractDecoderTest.php index c5ce37a6..cd999b0a 100644 --- a/tests/Drivers/AbstractDecoderTest.php +++ b/tests/Drivers/AbstractDecoderTest.php @@ -91,18 +91,31 @@ class AbstractDecoderTest extends TestCase }; $result = $decoder->parse( - 'data:image/gif;base64,R0lGODdhAwADAKIAAAQyrKTy/ByS7AQytLT2/AAAAAAAAAAAACwAAAAAAwADAAADBhgU0gMgAQA7' + 'data:image/gif;foo=bar;base64,R0lGODdhAwADAKIAAAQyrKTy/ByS7AQytLT2/AAAAAAAAAAAACwAAAAAAwADAAADBhgU0gMgAQA7' ); $this->assertTrue($result->isValid()); $this->assertEquals('image/gif', $result->mediaType()); $this->assertTrue($result->hasMediaType()); $this->assertTrue($result->isBase64Encoded()); - $this->assertEquals([], $result->parameters()); $this->assertEquals( 'R0lGODdhAwADAKIAAAQyrKTy/ByS7AQytLT2/AAAAAAAAAAAACwAAAAAAwADAAADBhgU0gMgAQA7', $result->data() ); + + $result = $decoder->parse('data:text/plain;charset=utf-8,test'); + $this->assertTrue($result->isValid()); + $this->assertEquals('text/plain', $result->mediaType()); + $this->assertTrue($result->hasMediaType()); + $this->assertFalse($result->isBase64Encoded()); + $this->assertEquals('test', $result->data()); + + $result = $decoder->parse('data:;charset=utf-8,'); + $this->assertTrue($result->isValid()); + $this->assertNull($result->mediaType()); + $this->assertFalse($result->hasMediaType()); + $this->assertFalse($result->isBase64Encoded()); + $this->assertNull($result->data()); } public function testIsValidBase64(): void