public static function stripCodes($text, $strip = self::STRIP_ALL)
    {
        if (!is_int($strip)) {
            throw new \Erebot\InvalidValueException("Invalid stripping flags");
        }

        if ($strip & self::STRIP_BOLD) {
            $text = str_replace("\002", '', $text);
        }

        if ($strip & self::STRIP_COLORS) {
            $text = preg_replace("/\003(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/", '', $text);
        }

        if ($strip & self::STRIP_RESET) {
            $text = str_replace("\017", '', $text);
        }

        if ($strip & self::STRIP_REVERSE) {
            $text = str_replace("\026", '', $text);
        }

        if ($strip & self::STRIP_UNDERLINE) {
            $text = str_replace("\037", '', $text);
        }

        return $text;
    }