File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ final public function __construct(float $value)
3030 */
3131 public static function fromNormalized (float $ normalized ): self
3232 {
33+ if ($ normalized < 0 || $ normalized > 1 ) {
34+ throw new InvalidArgumentException (
35+ 'Normalized color channel value of ' . static ::class . ' must be in range 0 to 1 ' ,
36+ );
37+ }
38+
3339 return new static (static ::min () + $ normalized * (static ::max () - static ::min ()));
3440 }
3541
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ final public function __construct(int $value)
3030 */
3131 public static function fromNormalized (float $ normalized ): self
3232 {
33+ if ($ normalized < 0 || $ normalized > 1 ) {
34+ throw new InvalidArgumentException (
35+ 'Normalized color channel value of ' . static ::class . ' must be in range 0 to 1 ' ,
36+ );
37+ }
38+
3339 return new static (intval (round ($ normalized * static ::max ())));
3440 }
3541
You can’t perform that action at this time.
0 commit comments