Color : phpstan l9

This commit is contained in:
2023-04-13 20:04:59 +02:00
parent 57cc0b261a
commit eed1fe690d

View File

@@ -1,6 +1,7 @@
<?php
/** DomFramework
/**
* DomFramework
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
@@ -8,12 +9,15 @@
namespace Domframework;
/** Convert the name of colors to RGB
/**
* Convert the name of colors to RGB
*/
class Color
{
/** The color list
/**
* The color list
* From http://www.rapidtables.com/web/color/index.htm
* @var array<string, array<int>>
*/
public $colorList = array(
// Black
@@ -52,7 +56,6 @@ class Color
"cornsilk" => array(255, 248, 220),
"blanchedalmond" => array(255, 235, 205),
"bisque" => array(255, 228, 196),
"navajowhite" => array(255, 222, 173),
"wheat" => array(245, 222, 179),
"burlywood" => array(222, 184, 135),
"tan" => array(210, 180, 140),
@@ -64,7 +67,6 @@ class Color
"saddlebrown" => array(139, 69, 19),
"sienna" => array(160, 82, 45),
"brown" => array(165, 42, 42),
"maroon" => array(128, 0, 0),
// Cyan
"lightcyan" => array(224, 255, 255),
@@ -77,22 +79,15 @@ class Color
"mediumturquoise" => array(72, 209, 204),
"darkturquoise" => array(0, 206, 209),
"lightseagreen" => array(32, 178, 170),
"cadetblue" => array(95, 158, 160),
"darkcyan" => array(0, 139, 139),
"teal" => array(0, 128, 128),
// Gold
"lightgoldenrodyellow" => array(250, 250, 210),
"palegoldenrod" => array(238, 232, 170),
"khaki" => array(240, 230, 140),
"goldenrod" => array(218, 165, 32),
"gold" => array(255, 215, 0),
"orange" => array(255, 165, 0),
"darkorange" => array(255, 140, 0),
"peru" => array(205, 133, 63),
"chocolate" => array(210, 105, 30),
"saddlebrown" => array(139, 69, 19),
"sienna" => array(160, 82, 45),
"goldenyellow" => array(255, 223, 0),
"metallicgold" => array(212, 175, 55),
"oldgold" => array(207, 181, 59),
@@ -116,7 +111,6 @@ class Color
"palegreen" => array(152, 251, 152),
"darkseagreen" => array(143, 188, 143),
"mediumseagreen" => array(60, 179, 113),
"lightseagreen" => array(32, 178, 170),
"seagreen" => array(46, 139, 87),
"olive" => array(128, 128, 0),
"darkolivegreen" => array(85, 107, 47),
@@ -126,35 +120,23 @@ class Color
"gainsboro" => array(220, 220, 220),
"lightgray" => array(211, 211, 211),
"lightgrey" => array(211, 211, 211),
"silver" => array(192, 192, 192),
"darkgray" => array(169, 169, 169),
"darkgrey" => array(169, 169, 169),
"gray" => array(128, 128, 128),
"grey" => array(128, 128, 128),
"dimgray" => array(105, 105, 105),
"dimgrey" => array(105, 105, 105),
"lightslategray" => array(119, 136, 153),
"lightslategrey" => array(119, 136, 153),
"slategray" => array(112, 128, 144),
"slategrey" => array(112, 128, 144),
"darkslategray" => array(47, 79, 79),
"darkslategrey" => array(47, 79, 79),
"black" => array(0, 0, 0),
// Maroon
"maroon" => array(128, 0, 0),
"darkred" => array(139, 0, 0),
"brown" => array(165, 42, 42),
"firebrick" => array(178, 34, 34),
"crimson" => array(220, 20, 60),
// Orange
"coral" => array(255, 127, 80),
"tomato" => array(255, 99, 71),
"orangered" => array(255, 69, 0),
"gold" => array(255, 215, 0),
"orange" => array(255, 165, 0),
"darkorange" => array(255, 140, 0),
// Pink
"pink" => array(255, 192, 203),
@@ -165,7 +147,6 @@ class Color
"mediumvioletred" => array(199, 21, 133),
// Purple
"lavender" => array(230, 230, 250),
"thistle" => array(216, 191, 216),
"plum" => array(221, 160, 221),
"violet" => array(238, 130, 238),
@@ -174,12 +155,10 @@ class Color
"magenta" => array(255, 0, 255),
"mediumorchid" => array(186, 85, 211),
"mediumpurple" => array(147, 112, 219),
"blueviolet" => array(138, 43, 226),
"darkviolet" => array(148, 0, 211),
"darkorchid" => array(153, 50, 204),
"darkmagenta" => array(139, 0, 139),
"purple" => array(128, 0, 128),
"indigo" => array(75, 0, 130),
// Red
"lightsalmon" => array(255, 160, 122),
@@ -191,10 +170,6 @@ class Color
"firebrick" => array(178, 34, 34),
"red" => array(255, 0, 0),
"darkred" => array(139, 0, 0),
"maroon" => array(128, 0, 0),
"tomato" => array(255, 99, 71),
"orangered" => array(255, 69, 0),
"palevioletred" => array(219, 112, 147),
// White
"white" => array(255, 255, 255),
@@ -202,7 +177,6 @@ class Color
"honeydew" => array(240, 255, 240),
"mintcream" => array(245, 255, 250),
"azure" => array(240, 255, 255),
"aliceblue" => array(240, 248, 255),
"ghostwhite" => array(248, 248, 255),
"whitesmoke" => array(245, 245, 245),
"seashell" => array(255, 245, 238),
@@ -223,13 +197,7 @@ class Color
"papayawhip" => array(255, 239, 213),
"moccasin" => array(255, 228, 181),
"peachpuff" => array(255, 218, 185),
"palegoldenrod" => array(238, 232, 170),
"khaki" => array(240, 230, 140),
"darkkhaki" => array(189, 183, 107),
"yellow" => array(255, 255, 0),
"olive" => array(128, 128, 0),
"greenyellow" => array(173, 255, 47),
"yellowgreen" => array(154, 205, 50),
"lightyellow1" => array(255, 255, 204),
"lightyellow2" => array(255, 255, 153),
"lightyellow3" => array(255, 255, 102),
@@ -241,21 +209,25 @@ class Color
"darkyellow4" => array(51, 51, 0),
);
/** Return the list of the known colors list
/**
* Return the list of the known colors list
* @return array<string>
*/
public static function colorList()
{
$color = new color();
$color = new Color();
$colorList = $color->colorList;
return array_keys($colorList);
}
/** Return an array with the RGB colors
/**
* Return an array with the RGB colors
* @param string $colorInText The color in textual form
* @return array<int>
*/
public static function textToRGB($colorInText)
{
$color = new color();
$color = new Color();
$colorList = $color->colorList;
if (! array_key_exists($colorInText, $colorList)) {
throw new \Exception(sprintf(
@@ -269,9 +241,11 @@ class Color
return $colorList[$colorInText];
}
/** Allocate the color provided in text to the provided GD object
* @param resource $gd The GD resource to add the color
/**
* Allocate the color provided in text to the provided GD object
* @param \GdImage $gd The GD resource to add the color
* @param string $colorInText The color in textual form
* @return int|false
*/
public static function allocateFromText($gd, $colorInText)
{
@@ -284,7 +258,7 @@ class Color
500
);
}
$rgb = color::textToRGB($colorInText);
$rgb = Color::textToRGB($colorInText);
return imagecolorallocate($gd, $rgb[0], $rgb[1], $rgb[2]);
}
}