@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $hex = $this->normalize($hex); |
| 48 | 48 | |
| 49 | - if(!$this->isValidHex($hex)) { |
|
| 49 | + if (!$this->isValidHex($hex)) { |
|
| 50 | 50 | throw new \InvalidArgumentException(sprintf('Given hex value %s is invalid', $hex)); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public function toRGB() |
| 72 | 72 | { |
| 73 | 73 | list($r, $g, $b) = sscanf($this->color, "%02x%02x%02x"); |
| 74 | - return [ $r, $g, $b ]; |
|
| 74 | + return [$r, $g, $b]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return self |
| 129 | 129 | */ |
| 130 | - public static function fromRGB($r,$g,$b) |
|
| 130 | + public static function fromRGB($r, $g, $b) |
|
| 131 | 131 | { |
| 132 | 132 | $hex = dechex($r).dechex($g).dechex($b); |
| 133 | 133 | |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | private function distanceL2(array $color1, array $color2) |
| 158 | 158 | { |
| 159 | 159 | return sqrt( |
| 160 | - pow($color1[0]-$color2[0], 2) + |
|
| 161 | - pow($color1[1]-$color2[1], 2) + |
|
| 162 | - pow($color1[2]-$color2[2], 2) |
|
| 160 | + pow($color1[0] - $color2[0], 2) + |
|
| 161 | + pow($color1[1] - $color2[1], 2) + |
|
| 162 | + pow($color1[2] - $color2[2], 2) |
|
| 163 | 163 | ); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | private function normalize($hex) |
| 212 | 212 | { |
| 213 | 213 | // Get rid of first # sign if it exists |
| 214 | - if($hex[0] === '#') { |
|
| 214 | + if ($hex[0] === '#') { |
|
| 215 | 215 | $hex = substr($hex, 1); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if(strlen($hex) === 3) { |
|
| 218 | + if (strlen($hex) === 3) { |
|
| 219 | 219 | // Convert to 6 digit version |
| 220 | 220 | $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; |
| 221 | 221 | } |