| @@ 21-32 (lines=12) @@ | ||
| 18 | $this->blue = $blue; |
|
| 19 | } |
|
| 20 | ||
| 21 | public static function fromString(string $string) |
|
| 22 | { |
|
| 23 | Validate::rgbColorString($string); |
|
| 24 | ||
| 25 | $matches = null; |
|
| 26 | preg_match('/rgb\( *(\d{1,3} *, *\d{1,3} *, *\d{1,3}) *\)/i', $string, $matches); |
|
| 27 | ||
| 28 | $channels = explode(',', $matches[1]); |
|
| 29 | list($red, $green, $blue) = array_map('trim', $channels); |
|
| 30 | ||
| 31 | return new static($red, $green, $blue); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function red(): int |
|
| 35 | { |
|
| @@ 26-37 (lines=12) @@ | ||
| 23 | $this->alpha = $alpha; |
|
| 24 | } |
|
| 25 | ||
| 26 | public static function fromString(string $string) |
|
| 27 | { |
|
| 28 | Validate::rgbaColorString($string); |
|
| 29 | ||
| 30 | $matches = null; |
|
| 31 | preg_match('/rgba\( *(\d{1,3} *, *\d{1,3} *, *\d{1,3} *, *[0-1](\.\d{1,2})?) *\)/i', $string, $matches); |
|
| 32 | ||
| 33 | $channels = explode(',', $matches[1]); |
|
| 34 | list($red, $green, $blue, $alpha) = array_map('trim', $channels); |
|
| 35 | ||
| 36 | return new static($red, $green, $blue, $alpha); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function red(): int |
|
| 40 | { |
|