| Conditions | 2 |
| Paths | 2 |
| Total Lines | 157 |
| Code Lines | 153 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 7 | function _resolve_htmlcolor($color) { |
||
| 8 | $htmlcolors = array( |
||
| 9 | "aliceblue" => "#f0f8ff", |
||
| 10 | "antiquewhite" => "#faebd7", |
||
| 11 | "aqua" => "#00ffff", |
||
| 12 | "aquamarine" => "#7fffd4", |
||
| 13 | "azure" => "#f0ffff", |
||
| 14 | "beige" => "#f5f5dc", |
||
| 15 | "bisque" => "#ffe4c4", |
||
| 16 | "black" => "#000000", |
||
| 17 | "blanchedalmond" => "#ffebcd", |
||
| 18 | "blue" => "#0000ff", |
||
| 19 | "blueviolet" => "#8a2be2", |
||
| 20 | "brown" => "#a52a2a", |
||
| 21 | "burlywood" => "#deb887", |
||
| 22 | "cadetblue" => "#5f9ea0", |
||
| 23 | "chartreuse" => "#7fff00", |
||
| 24 | "chocolate" => "#d2691e", |
||
| 25 | "coral" => "#ff7f50", |
||
| 26 | "cornflowerblue" => "#6495ed", |
||
| 27 | "cornsilk" => "#fff8dc", |
||
| 28 | "crimson" => "#dc143c", |
||
| 29 | "cyan" => "#00ffff", |
||
| 30 | "darkblue" => "#00008b", |
||
| 31 | "darkcyan" => "#008b8b", |
||
| 32 | "darkgoldenrod" => "#b8860b", |
||
| 33 | "darkgray" => "#a9a9a9", |
||
| 34 | "darkgrey" => "#a9a9a9", |
||
| 35 | "darkgreen" => "#006400", |
||
| 36 | "darkkhaki" => "#bdb76b", |
||
| 37 | "darkmagenta" => "#8b008b", |
||
| 38 | "darkolivegreen" => "#556b2f", |
||
| 39 | "darkorange" => "#ff8c00", |
||
| 40 | "darkorchid" => "#9932cc", |
||
| 41 | "darkred" => "#8b0000", |
||
| 42 | "darksalmon" => "#e9967a", |
||
| 43 | "darkseagreen" => "#8fbc8f", |
||
| 44 | "darkslateblue" => "#483d8b", |
||
| 45 | "darkslategray" => "#2f4f4f", |
||
| 46 | "darkslategrey" => "#2f4f4f", |
||
| 47 | "darkturquoise" => "#00ced1", |
||
| 48 | "darkviolet" => "#9400d3", |
||
| 49 | "deeppink" => "#ff1493", |
||
| 50 | "deepskyblue" => "#00bfff", |
||
| 51 | "dimgray" => "#696969", |
||
| 52 | "dimgrey" => "#696969", |
||
| 53 | "dodgerblue" => "#1e90ff", |
||
| 54 | "firebrick" => "#b22222", |
||
| 55 | "floralwhite" => "#fffaf0", |
||
| 56 | "forestgreen" => "#228b22", |
||
| 57 | "fuchsia" => "#ff00ff", |
||
| 58 | "gainsboro" => "#dcdcdc", |
||
| 59 | "ghostwhite" => "#f8f8ff", |
||
| 60 | "gold" => "#ffd700", |
||
| 61 | "goldenrod" => "#daa520", |
||
| 62 | "gray" => "#808080", |
||
| 63 | "grey" => "#808080", |
||
| 64 | "green" => "#008000", |
||
| 65 | "greenyellow" => "#adff2f", |
||
| 66 | "honeydew" => "#f0fff0", |
||
| 67 | "hotpink" => "#ff69b4", |
||
| 68 | "indianred " => "#cd5c5c", |
||
| 69 | "indigo " => "#4b0082", |
||
| 70 | "ivory" => "#fffff0", |
||
| 71 | "khaki" => "#f0e68c", |
||
| 72 | "lavender" => "#e6e6fa", |
||
| 73 | "lavenderblush" => "#fff0f5", |
||
| 74 | "lawngreen" => "#7cfc00", |
||
| 75 | "lemonchiffon" => "#fffacd", |
||
| 76 | "lightblue" => "#add8e6", |
||
| 77 | "lightcoral" => "#f08080", |
||
| 78 | "lightcyan" => "#e0ffff", |
||
| 79 | "lightgoldenrodyellow" => "#fafad2", |
||
| 80 | "lightgray" => "#d3d3d3", |
||
| 81 | "lightgrey" => "#d3d3d3", |
||
| 82 | "lightgreen" => "#90ee90", |
||
| 83 | "lightpink" => "#ffb6c1", |
||
| 84 | "lightsalmon" => "#ffa07a", |
||
| 85 | "lightseagreen" => "#20b2aa", |
||
| 86 | "lightskyblue" => "#87cefa", |
||
| 87 | "lightslategray" => "#778899", |
||
| 88 | "lightslategrey" => "#778899", |
||
| 89 | "lightsteelblue" => "#b0c4de", |
||
| 90 | "lightyellow" => "#ffffe0", |
||
| 91 | "lime" => "#00ff00", |
||
| 92 | "limegreen" => "#32cd32", |
||
| 93 | "linen" => "#faf0e6", |
||
| 94 | "magenta" => "#ff00ff", |
||
| 95 | "maroon" => "#800000", |
||
| 96 | "mediumaquamarine" => "#66cdaa", |
||
| 97 | "mediumblue" => "#0000cd", |
||
| 98 | "mediumorchid" => "#ba55d3", |
||
| 99 | "mediumpurple" => "#9370db", |
||
| 100 | "mediumseagreen" => "#3cb371", |
||
| 101 | "mediumslateblue" => "#7b68ee", |
||
| 102 | "mediumspringgreen" => "#00fa9a", |
||
| 103 | "mediumturquoise" => "#48d1cc", |
||
| 104 | "mediumvioletred" => "#c71585", |
||
| 105 | "midnightblue" => "#191970", |
||
| 106 | "mintcream" => "#f5fffa", |
||
| 107 | "mistyrose" => "#ffe4e1", |
||
| 108 | "moccasin" => "#ffe4b5", |
||
| 109 | "navajowhite" => "#ffdead", |
||
| 110 | "navy" => "#000080", |
||
| 111 | "oldlace" => "#fdf5e6", |
||
| 112 | "olive" => "#808000", |
||
| 113 | "olivedrab" => "#6b8e23", |
||
| 114 | "orange" => "#ffa500", |
||
| 115 | "orangered" => "#ff4500", |
||
| 116 | "orchid" => "#da70d6", |
||
| 117 | "palegoldenrod" => "#eee8aa", |
||
| 118 | "palegreen" => "#98fb98", |
||
| 119 | "paleturquoise" => "#afeeee", |
||
| 120 | "palevioletred" => "#db7093", |
||
| 121 | "papayawhip" => "#ffefd5", |
||
| 122 | "peachpuff" => "#ffdab9", |
||
| 123 | "peru" => "#cd853f", |
||
| 124 | "pink" => "#ffc0cb", |
||
| 125 | "plum" => "#dda0dd", |
||
| 126 | "powderblue" => "#b0e0e6", |
||
| 127 | "purple" => "#800080", |
||
| 128 | "red" => "#ff0000", |
||
| 129 | "rosybrown" => "#bc8f8f", |
||
| 130 | "royalblue" => "#4169e1", |
||
| 131 | "saddlebrown" => "#8b4513", |
||
| 132 | "salmon" => "#fa8072", |
||
| 133 | "sandybrown" => "#f4a460", |
||
| 134 | "seagreen" => "#2e8b57", |
||
| 135 | "seashell" => "#fff5ee", |
||
| 136 | "sienna" => "#a0522d", |
||
| 137 | "silver" => "#c0c0c0", |
||
| 138 | "skyblue" => "#87ceeb", |
||
| 139 | "slateblue" => "#6a5acd", |
||
| 140 | "slategray" => "#708090", |
||
| 141 | "slategrey" => "#708090", |
||
| 142 | "snow" => "#fffafa", |
||
| 143 | "springgreen" => "#00ff7f", |
||
| 144 | "steelblue" => "#4682b4", |
||
| 145 | "tan" => "#d2b48c", |
||
| 146 | "teal" => "#008080", |
||
| 147 | "thistle" => "#d8bfd8", |
||
| 148 | "tomato" => "#ff6347", |
||
| 149 | "turquoise" => "#40e0d0", |
||
| 150 | "violet" => "#ee82ee", |
||
| 151 | "wheat" => "#f5deb3", |
||
| 152 | "white" => "#ffffff", |
||
| 153 | "whitesmoke" => "#f5f5f5", |
||
| 154 | "yellow" => "#ffff00", |
||
| 155 | "yellowgreen" => "#9acd32" |
||
| 156 | ); |
||
| 157 | |||
| 158 | $color = strtolower($color); |
||
| 159 | |||
| 160 | if (isset($htmlcolors[$color])) { |
||
| 161 | return $htmlcolors[$color]; |
||
| 162 | } else { |
||
| 163 | return $color; |
||
| 164 | } |
||
| 376 |