diff --git a/src/ColorModels/HueSaturationValue.php b/src/ColorModels/HueSaturationValue.php new file mode 100644 index 0000000..ccd8634 --- /dev/null +++ b/src/ColorModels/HueSaturationValue.php @@ -0,0 +1,77 @@ +hue; + } + + /** + * @param float $hue + * @return HueSaturationValue + */ + public function setHue(float $hue): HueSaturationValue + { + $this->checkValue($hue); + $this->hue = $hue; + return $this; + } + + /** + * @return float + */ + public function getSaturation(): float + { + return $this->saturation; + } + + /** + * @param float $saturation + * @return HueSaturationValue + */ + public function setSaturation(float $saturation): HueSaturationValue + { + $this->checkValue($saturation); + $this->saturation = $saturation; + return $this; + } + + /** + * @return float + */ + public function getValue(): float + { + return $this->value; + } + + /** + * @param float $value + * @return HueSaturationValue + */ + public function setValue(float $value): HueSaturationValue + { + $this->checkValue($value); + $this->value = $value; + return $this; + } + + +} \ No newline at end of file diff --git a/tests/unit/ColorModels/HueSaturationValueTest.php b/tests/unit/ColorModels/HueSaturationValueTest.php new file mode 100644 index 0000000..7a57300 --- /dev/null +++ b/tests/unit/ColorModels/HueSaturationValueTest.php @@ -0,0 +1,97 @@ +assertEquals(0.0, $color->getHue()); + $this->assertEquals(0.0, $color->getSaturation()); + $this->assertEquals(1.0, $color->getValue()); + } + + /** + * @param float $value + * + * @dataProvider validValueProvider + */ + public function testSetHueWithValidValue(float $value) + { + $color = new HueSaturationValue(); + + $color->setHue($value); + $this->assertEquals($value, $color->getHue()); + } + + /** + * @param float $value + * + * @dataProvider invalidValueProvider + */ + public function testSetHueWithInvalidValue(float $value) + { + $color = new HueSaturationValue(); + + $this->expectException(InvalidArgumentException::class); + $color->setHue($value); + } + + /** + * @param float $value + * + * @dataProvider validValueProvider + */ + public function testSetSaturationWithValidValue(float $value) + { + $color = new HueSaturationValue(); + + $color->setSaturation($value); + $this->assertEquals($value, $color->getSaturation()); + } + + /** + * @param float $value + * + * @dataProvider invalidValueProvider + */ + public function testSetSaturationWithInvalidValue(float $value) + { + $color = new HueSaturationValue(); + + $this->expectException(InvalidArgumentException::class); + $color->setSaturation($value); + } + + /** + * @param float $value + * + * @dataProvider validValueProvider + */ + public function testSetValueWithValidValue(float $value) + { + $color = new HueSaturationValue(); + + $color->setValue($value); + $this->assertEquals($value, $color->getValue()); + } + + /** + * @param float $value + * + * @dataProvider invalidValueProvider + */ + public function testSetValueWithInvalidValue(float $value) + { + $color = new HueSaturationValue(); + + $this->expectException(InvalidArgumentException::class); + $color->setValue($value); + } +}