public static function encoding(string $str = null) : string
    {
        // If a string was given, we attempt to detect the encoding of the string if we are told to do so.
        // If we succeed, just return the determined type.
        if (true === static::$autoDetectEncoding && null !== $str && false !== $encoding = mb_detect_encoding($str)) {
            return $encoding;
        }

        // Otherwise let's return one of the defaults.
        return static::$encoding ?: 'utf-8';
    }