diff --git a/src/OptionSet.php b/src/OptionSet.php index 1cc5fa9..e2ce4a2 100644 --- a/src/OptionSet.php +++ b/src/OptionSet.php @@ -19,6 +19,11 @@ private function set(string $name, ...$args): self return $this; } + public function setUnsafe(string $name, ...$args): self + { + return $this->set($name, ...$args); + } + public function unset(string $name): self { unset($this->options[$name]); diff --git a/test/OptionSetTest.php b/test/OptionSetTest.php index 98e3c32..379d22f 100644 --- a/test/OptionSetTest.php +++ b/test/OptionSetTest.php @@ -11,6 +11,7 @@ use Imgproxy\UnsharpeningMode; use Imgproxy\WatermarkPosition; use PHPUnit\Framework\TestCase; +use ReflectionClass; class OptionSetTest extends TestCase { @@ -973,6 +974,23 @@ public function testWithQuality() $this->assertEquals(70, $os->quality()); } + public function testSetUnsafe(): void + { + $os = new OptionSet(); + $optionName = 'zoom'; + $args = ['2', '2']; + + $os->setUnsafe($optionName, ...$args); + + $reflectionClass = new ReflectionClass(OptionSet::class); + $optionsProperty = $reflectionClass->getProperty('options'); + $optionsProperty->setAccessible(true); + $options = $optionsProperty->getValue($os); + + $this->assertArrayHasKey($optionName, $options); + $this->assertSame($args, $options[$optionName]); + } + public function testUnset() { $os = new OptionSet();