src/Transcoder.php
public static function create($defaultEncoding = 'UTF-8')
    {
        if (isset(self::$chain[$defaultEncoding])) {
            return self::$chain[$defaultEncoding];
        }
        
        $transcoders = [];
        
        try {
            $transcoders[] = new MbTranscoder($defaultEncoding);
        } catch (ExtensionMissingException $mb) {
            // Ignore missing mbstring extension; fall back to iconv
        }

        try {
            $transcoders[] = new IconvTranscoder($defaultEncoding);
        } catch (ExtensionMissingException $iconv) {
            // Neither mbstring nor iconv
            throw $iconv;
        }
        
        self::$chain[$defaultEncoding] = new self($transcoders);

        return self::$chain[$defaultEncoding];
    }
public static function create($defaultEncoding = 'UTF-8')
    {
        if (isset(self::$chain[$defaultEncoding])) {
            return self::$chain[$defaultEncoding];
        }
        
        $transcoders = [];
        
        try {
            $transcoders[] = new MbTranscoder($defaultEncoding);
        } catch (ExtensionMissingException $mb) {
            // Ignore missing mbstring extension; fall back to iconv
        }

        try {
            $transcoders[] = new IconvTranscoder($defaultEncoding);
        } catch (ExtensionMissingException $iconv) {
            // Neither mbstring nor iconv
            throw $iconv;
        }
        
        self::$chain[$defaultEncoding] = new self($transcoders);

        return self::$chain[$defaultEncoding];
    }
public static function create ( $ defaultEncoding = 'UTF-8' ) { if ( isset ( self :: $ chain [ $ defaultEncoding ] ) ) { return self :: $ chain [ $ defaultEncoding ] ; } $ transcoders = [ ] ; try { $ transcoders [ ] = new MbTranscoder ( $ defaultEncoding ) ; } catch ( ExtensionMissingException $ mb ) { // Ignore missing mbstring extension; fall back to iconv } try { $ transcoders [ ] = new IconvTranscoder ( $ defaultEncoding ) ; } catch ( ExtensionMissingException $ iconv ) { // Neither mbstring nor iconv throw $ iconv ; } self :: $ chain [ $ defaultEncoding ] = new self ( $ transcoders ) ; return self :: $ chain [ $ defaultEncoding ] ; }
Create a transcoder

@param string $defaultEncoding

@return TranscoderInterface

@throws ExtensionMissingException
Create a transcoder