@@ -129,7 +129,7 @@ |
||
| 129 | 129 | * @param float $hue The hue (to be converted to an RGB value) For red, add 1/3 to the hue, green |
| 130 | 130 | * leave it alone, and blue you subtract 1/3 from the hue. |
| 131 | 131 | * |
| 132 | - * @return mixed |
|
| 132 | + * @return double |
|
| 133 | 133 | */ |
| 134 | 134 | private static function hueToRgb($p, $q, $hue): float |
| 135 | 135 | { |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return [ |
| 113 | - 'r' => (int)hexdec(substr($color, 0, 2)), |
|
| 114 | - 'g' => (int)hexdec(substr($color, 2, 2)), |
|
| 115 | - 'b' => (int)hexdec(substr($color, 4, 2)), |
|
| 113 | + 'r' => (int) hexdec(substr($color, 0, 2)), |
|
| 114 | + 'g' => (int) hexdec(substr($color, 2, 2)), |
|
| 115 | + 'b' => (int) hexdec(substr($color, 4, 2)), |
|
| 116 | 116 | ]; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | // If saturation is 0, the given color is grey and only |
| 173 | 173 | // lightness is relevant. |
| 174 | 174 | if ($saturation == 0) { |
| 175 | - $lightness = (int)ceil($lightness * 255); |
|
| 175 | + $lightness = (int) ceil($lightness * 255); |
|
| 176 | 176 | |
| 177 | 177 | return ['r' => $lightness, 'g' => $lightness, 'b' => $lightness]; |
| 178 | 178 | } |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | $blue = self::hueToRgb($p, $q, $hue - 1 / 3); |
| 193 | 193 | |
| 194 | 194 | return [ |
| 195 | - 'r' => (int)round($red * 255, 2), |
|
| 196 | - 'g' => (int)round(round($green, 2) * 255), |
|
| 197 | - 'b' => (int)round($blue * 255, 2), |
|
| 195 | + 'r' => (int) round($red * 255, 2), |
|
| 196 | + 'g' => (int) round(round($green, 2) * 255), |
|
| 197 | + 'b' => (int) round($blue * 255, 2), |
|
| 198 | 198 | ]; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | { |
| 287 | 287 | $color2 = $color->getRgb(); |
| 288 | 288 | |
| 289 | - return (int)abs($this->colors['r'] - $color2['r']) |
|
| 290 | - + (int)abs($this->colors['g'] - $color2['g']) |
|
| 291 | - + (int)abs($this->colors['b'] - $color2['b']); |
|
| 289 | + return (int) abs($this->colors['r'] - $color2['r']) |
|
| 290 | + + (int) abs($this->colors['g'] - $color2['g']) |
|
| 291 | + + (int) abs($this->colors['b'] - $color2['b']); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | $mixWeight = $steps - $weight; |
| 342 | 342 | |
| 343 | 343 | $mixedColor = [ |
| 344 | - 'r' => (int)ceil((($this->getRgb()['r'] * $weight) + ($color->getRgb()['r'] * $mixWeight)) / $steps), |
|
| 345 | - 'g' => (int)ceil((($this->getRgb()['g'] * $weight) + ($color->getRgb()['g'] * $mixWeight)) / $steps), |
|
| 346 | - 'b' => (int)ceil((($this->getRgb()['b'] * $weight) + ($color->getRgb()['b'] * $mixWeight)) / $steps), |
|
| 344 | + 'r' => (int) ceil((($this->getRgb()['r'] * $weight) + ($color->getRgb()['r'] * $mixWeight)) / $steps), |
|
| 345 | + 'g' => (int) ceil((($this->getRgb()['g'] * $weight) + ($color->getRgb()['g'] * $mixWeight)) / $steps), |
|
| 346 | + 'b' => (int) ceil((($this->getRgb()['b'] * $weight) + ($color->getRgb()['b'] * $mixWeight)) / $steps), |
|
| 347 | 347 | ]; |
| 348 | 348 | |
| 349 | 349 | return new self(...array_values($mixedColor)); |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | public function lighten(float $percentage): Color |
| 476 | 476 | { |
| 477 | - $colors = $this->getHsl(); |
|
| 477 | + $colors = $this->getHsl(); |
|
| 478 | 478 | $colors['l'] += $colors['l'] * ($percentage / 100); |
| 479 | 479 | |
| 480 | 480 | $lighterColor = self::hslToRgb($colors['h'], $colors['s'], min(round($colors['l'], 5), 1)); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace MikeAlmond\Color; |
| 6 | 6 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | public static function isValidRgb(int $red, int $green, int $blue) : bool |
| 28 | 28 | { |
| 29 | 29 | // Check to see the values are between 0 and 255 and return false if any are outside the bounds |
| 30 | - return array_reduce([$red, $green, $blue], function ($carry, $color) { |
|
| 30 | + return array_reduce([$red, $green, $blue], function($carry, $color) { |
|
| 31 | 31 | return max(min(intval($color), 255), 0) === $color && $carry === true; |
| 32 | 32 | }, true); |
| 33 | 33 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public static function isValidHsl(float $hue, float $saturation, float $lightness) : bool |
| 44 | 44 | { |
| 45 | 45 | // Check to see the values are between 0 and 1 and return false if any are outside the bounds |
| 46 | - return array_reduce([$hue, $saturation, $lightness], function ($carry, $color) { |
|
| 46 | + return array_reduce([$hue, $saturation, $lightness], function($carry, $color) { |
|
| 47 | 47 | return $color >= 0 && $color <= 1 && $carry === true; |
| 48 | 48 | }, true); |
| 49 | 49 | } |