public function assertHex(string $hex)
    {
        // Assert HEX value length.
        if (mb_strlen($hex) !== 7) {
            throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
        }

        // Assert HEX value first character.
        if (mb_substr($hex, 0, 1) !== '#') {
            throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
        }

        for ($i = 1; $i < mb_strlen($hex); $i++) {
            // Assert HEX digit value.
            if (!ctype_xdigit($hex[$i])) {
                throw new RuntimeException(sprintf('Invalid HEX value %s.', $hex));
            }
        }
    }