Skip to content

Commit 93a535c

Browse files
committed
- Added Override attributes.
- Updated Composer. - Updated README.
1 parent 514dece commit 93a535c

24 files changed

Lines changed: 129 additions & 26 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ $space = $color->space();
281281

282282
Convert the *Color* to a named color space.
283283

284-
- `$space` is a string representing the color space, and must be one of either "*a98-rgb*", "*display-p3*", "*display-p3-linear*", "*hex*", "*hsl*", "hwb**", "*lab*", "*lch*", "*oklab*", "*oklch*", "*prophoto-rgb*", "*rec2020*", "*rgb*", "*srgb*", "*srgb-linear*", "*xyz-d50*" or "*xyz-d65*".
284+
- `$space` is a string representing the color space, and must be one of either "*a98-rgb*", "*display-p3*", "*display-p3-linear*", "*hex*", "*hsl*", "*hwb*", "*lab*", "*lch*", "*oklab*", "*oklch*", "*prophoto-rgb*", "*rec2020*", "*rgb*", "*srgb*", "*srgb-linear*", "*xyz-d50*" or "*xyz-d65*".
285285

286286
```php
287287
$newColor = $color->to($space);

composer.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ public function to(string $space): Color
686686
}
687687

688688
if (!array_key_exists($space, static::CONVERSION_MAP)) {
689-
throw new InvalidArgumentException('Invalid Color space: '.$space);
689+
throw new InvalidArgumentException('Invalid color space: '.$space);
690690
}
691691

692692
return $this->{static::CONVERSION_MAP[$space]}();

src/Colors/A98Rgb.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Fyre\Color\Color;
77
use Fyre\Color\ColorConverter;
88
use Fyre\Color\Traits\RgbTrait;
9+
use Override;
910

1011
/**
1112
* A98Rgb
@@ -21,6 +22,7 @@ class A98Rgb extends Color
2122
*
2223
* @return A98Rgb The A98Rgb Color.
2324
*/
25+
#[Override]
2426
public function toA98Rgb(): A98Rgb
2527
{
2628
return $this;
@@ -31,6 +33,7 @@ public function toA98Rgb(): A98Rgb
3133
*
3234
* @return XyzD65 The XyzD65 Color.
3335
*/
36+
#[Override]
3437
public function toXyzD65(): XyzD65
3538
{
3639
[$x, $y, $z] = ColorConverter::a98RgbToXyzD65($this->red, $this->green, $this->blue);

src/Colors/DisplayP3.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Fyre\Color\Color;
77
use Fyre\Color\ColorConverter;
88
use Fyre\Color\Traits\RgbTrait;
9+
use Override;
910

1011
/**
1112
* DisplayP3
@@ -21,6 +22,7 @@ class DisplayP3 extends Color
2122
*
2223
* @return DisplayP3 The DisplayP3 Color.
2324
*/
25+
#[Override]
2426
public function toDisplayP3(): DisplayP3
2527
{
2628
return $this;
@@ -31,6 +33,7 @@ public function toDisplayP3(): DisplayP3
3133
*
3234
* @return DisplayP3Linear The DisplayP3Linear Color.
3335
*/
36+
#[Override]
3437
public function toDisplayP3Linear(): DisplayP3Linear
3538
{
3639
[$r, $g, $b] = ColorConverter::displayP3ToDisplayP3Linear($this->red, $this->green, $this->blue);
@@ -43,6 +46,7 @@ public function toDisplayP3Linear(): DisplayP3Linear
4346
*
4447
* @return XyzD65 The XyzD65 Color.
4548
*/
49+
#[Override]
4650
public function toXyzD65(): XyzD65
4751
{
4852
return $this->toDisplayP3Linear()->toXyzD65();

src/Colors/DisplayP3Linear.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Fyre\Color\Color;
77
use Fyre\Color\ColorConverter;
88
use Fyre\Color\Traits\RgbTrait;
9+
use Override;
910

1011
/**
1112
* DisplayP3Linear
@@ -21,6 +22,7 @@ class DisplayP3Linear extends Color
2122
*
2223
* @return DisplayP3 The DisplayP3 Color.
2324
*/
25+
#[Override]
2426
public function toDisplayP3(): DisplayP3
2527
{
2628
[$r, $g, $b] = ColorConverter::displayP3LinearToDisplayP3($this->red, $this->green, $this->blue);
@@ -33,6 +35,7 @@ public function toDisplayP3(): DisplayP3
3335
*
3436
* @return DisplayP3Linear The DisplayP3Linear Color.
3537
*/
38+
#[Override]
3639
public function toDisplayP3Linear(): DisplayP3Linear
3740
{
3841
return $this;
@@ -43,6 +46,7 @@ public function toDisplayP3Linear(): DisplayP3Linear
4346
*
4447
* @return XyzD65 The XyzD65 Color.
4548
*/
49+
#[Override]
4650
public function toXyzD65(): XyzD65
4751
{
4852
[$x, $y, $z] = ColorConverter::displayP3LinearToXyzD65($this->red, $this->green, $this->blue);

src/Colors/Hex.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace Fyre\Color\Colors;
55

6+
use Override;
7+
68
/**
79
* Hex
810
*/
@@ -15,6 +17,7 @@ class Hex extends Rgb
1517
*
1618
* @return Hex The Hex Color.
1719
*/
20+
#[Override]
1821
public function toHex(): Hex
1922
{
2023
return $this;
@@ -25,6 +28,7 @@ public function toHex(): Hex
2528
*
2629
* @return Rgb The Rgb Color.
2730
*/
31+
#[Override]
2832
public function toRgb(): Rgb
2933
{
3034
return new Rgb($this->red, $this->green, $this->blue, $this->alpha);
@@ -39,6 +43,7 @@ public function toRgb(): Rgb
3943
* @param bool $name Whether to use CSS color names.
4044
* @return string The CSS color string.
4145
*/
46+
#[Override]
4247
public function toString(bool|null $alpha = null, int $precision = 2, bool $shortenHex = true, bool $name = false): string
4348
{
4449
$alpha ??= $this->alpha < 1;

src/Colors/Hsl.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Fyre\Color\Color;
77
use Fyre\Color\ColorConverter;
8+
use Override;
89

910
use function max;
1011
use function round;
@@ -77,6 +78,7 @@ public function getSaturation(): float
7778
*
7879
* @return array The color components.
7980
*/
81+
#[Override]
8082
public function toArray(): array
8183
{
8284
return [
@@ -92,6 +94,7 @@ public function toArray(): array
9294
*
9395
* @return Hsl The Hsl Color.
9496
*/
97+
#[Override]
9598
public function toHsl(): Hsl
9699
{
97100
return $this;
@@ -102,6 +105,7 @@ public function toHsl(): Hsl
102105
*
103106
* @return Srgb The Srgb Color.
104107
*/
108+
#[Override]
105109
public function toSrgb(): Srgb
106110
{
107111
[$r, $g, $b] = ColorConverter::hslToSrgb($this->hue, $this->saturation / 100, $this->lightness / 100);
@@ -114,6 +118,7 @@ public function toSrgb(): Srgb
114118
*
115119
* @return SrgbLinear The SrgbLinear Color.
116120
*/
121+
#[Override]
117122
public function toSrgbLinear(): SrgbLinear
118123
{
119124
return $this->toSrgb()->toSrgbLinear();
@@ -126,6 +131,7 @@ public function toSrgbLinear(): SrgbLinear
126131
* @param int $precision The decimal precision.
127132
* @return string The CSS color string.
128133
*/
134+
#[Override]
129135
public function toString(bool|null $alpha = null, int $precision = 2): string
130136
{
131137
$alpha ??= $this->alpha < 1;

src/Colors/Hwb.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Fyre\Color\Color;
77
use Fyre\Color\ColorConverter;
8+
use Override;
89

910
use function max;
1011
use function round;
@@ -77,6 +78,7 @@ public function getWhiteness(): float
7778
*
7879
* @return array The color components.
7980
*/
81+
#[Override]
8082
public function toArray(): array
8183
{
8284
return [
@@ -87,6 +89,12 @@ public function toArray(): array
8789
];
8890
}
8991

92+
/**
93+
* Convert the Color to Hwb.
94+
*
95+
* @return Hwb The Hwb Color.
96+
*/
97+
#[Override]
9098
public function toHwb(): Hwb
9199
{
92100
return $this;
@@ -97,6 +105,7 @@ public function toHwb(): Hwb
97105
*
98106
* @return Srgb The Srgb Color.
99107
*/
108+
#[Override]
100109
public function toSrgb(): Srgb
101110
{
102111
[$r, $g, $b] = ColorConverter::hwbToSrgb($this->hue, $this->whiteness / 100, $this->blackness / 100);
@@ -109,6 +118,7 @@ public function toSrgb(): Srgb
109118
*
110119
* @return SrgbLinear The SrgbLinear Color.
111120
*/
121+
#[Override]
112122
public function toSrgbLinear(): SrgbLinear
113123
{
114124
return $this->toSrgb()->toSrgbLinear();
@@ -121,6 +131,7 @@ public function toSrgbLinear(): SrgbLinear
121131
* @param int $precision The decimal precision.
122132
* @return string The CSS color string.
123133
*/
134+
#[Override]
124135
public function toString(bool|null $alpha = null, int $precision = 2): string
125136
{
126137
$alpha ??= $this->alpha < 1;

0 commit comments

Comments
 (0)