src/Encoder/Base32Encoder.php
public function decode($string)
    {
        $decoded = '';
        $string = preg_replace("/[^{$this->charset}]/", '', rtrim(strtoupper($string), $this->charset[32]));

        if ($string) {
            $binString = '';
            foreach (str_split($string) as $char) {
                $binString .= str_pad(decbin(strpos($this->charset, $char)), 5, 0, STR_PAD_LEFT);
            }
            $binString = substr($binString, 0, (floor(strlen($binString) / 8) * 8));

            foreach (str_split($binString, 8) as $chunk) {
                $chunk = str_pad($chunk, 8, 0, STR_PAD_RIGHT);
                $decoded .= chr(bindec($chunk));
            }
        }

        return $decoded;
    }
public function decode($string)
    {
        $decoded = '';
        $string = preg_replace("/[^{$this->charset}]/", '', rtrim(strtoupper($string), $this->charset[32]));

        if ($string) {
            $binString = '';
            foreach (str_split($string) as $char) {
                $binString .= str_pad(decbin(strpos($this->charset, $char)), 5, 0, STR_PAD_LEFT);
            }
            $binString = substr($binString, 0, (floor(strlen($binString) / 8) * 8));

            foreach (str_split($binString, 8) as $chunk) {
                $chunk = str_pad($chunk, 8, 0, STR_PAD_RIGHT);
                $decoded .= chr(bindec($chunk));
            }
        }

        return $decoded;
    }
Decode an encoded string.

@param  string $string
@return string