Converts an unpacked binary string into a printable IP

@author Mike Mackintosh - mike@bakeryphp.com
@link http://www.highonphp.com/5-tips-for-working-with-ipv6-in-php
@param string $str
@return string $ip
163578
public static function expandIp($str) 
    {
        if (strlen($str) == 16 OR strlen($str) == 4) {
            return inet_ntop(pack("A".strlen($str), $str));
        }
        return false;
    }
828486
protected function modifyHost(string $str): string
    {
        return (string) $this->filterHost($str)->getContent(EncodingInterface::RFC3987_ENCODING);
    }
835641
static public function fromCamel($str) {
      $str[0] = strtolower($str[0]);
      return preg_replace_callback('/([A-Z])/', function($char) {return "_" . strtolower($char[1]);}, $str);
  }
82265
private function _strtoupper($str)
    {
        $str = html_entity_decode($str, ENT_COMPAT);

        if (function_exists('mb_strtoupper')) {
            $str = mb_strtoupper($str, 'UTF-8');
        } else {
            $str = strtoupper($str);
        }

        $str = htmlspecialchars($str, ENT_COMPAT);

        return $str;
    }
692261
private function doUnserialize($str)
    {
        $m = $this->allowedClasses ? @unserialize($str, [
            'allowed_classes' => $this->allowedClasses,
        ]) : @unserialize($str);

        if (false === $m) {
            $err = error_get_last();
            throw new SerializationError(sprintf(
                'Error unserializing message: %s', 
                $err && isset($err['message']) ? $err['message'] : 'unknown error'
            ));
        }

        return $m;
    }
8185
public function str2unicode($str)
    {
        $uni = '';
        $str = (string) $str;
        for ($i = 0; $i < strlen($str); $i++) {
            $a = ord($str{$i}) << 8;
            $uni .= sprintf("%X", $a);
        }
        return pack('H*', $uni);
    }
332267
private function unescapeLatinCharacters($str)
    {
        if ($this->latinCharacters) {
            $str = vsprintf($str, $this->latinCharacters);
            $this->latinCharacters = array();
        }

        return $str;
    }
216852
public function writeOutput($str)
    {
        if (empty($str)) {
            return $this;
        }

        $this->output[] = $str;

        if ($this->consoleOutput) {
            $this->consoleOutput->writeln($str);
        }

        return $this;
    }
1127323
public static function DJPHash( $str ) {

        //$hcode = 5381;
        $hcode = 53;
        $len = strlen($str);
        for ( $i = 0; $i < $len; $i++ ) {
            $hcode += ($hcode << 5) + ord($str[$i]);
        }
        return ($hcode & 0x7FFFFFFF);
    }
1051228
public static function toInt(string $str) : int
    {
        $result = 0;
        $str    = mb_convert_kana(self::replaceRoman($str), 'a');
        foreach (self::$romans as $key => $value) {
            while (mb_strpos($str, $key) === 0) {
                $result += $value;
                $str = mb_substr($str, strlen($key));
            }
        }
        return $result;
    }
199318
public static function encode(String $str) : String
    {
        return str_replace(array_keys(self::$phpTagChars), array_values(self::$phpTagChars), $str);
    }
392889
private function getHost($ipStr)
    {
        $ip = IP::fromStringIP($ipStr);

        $host = $ip->getHostname();
        $host = ($host === null ? $ipStr : $host);

        return trim(strtolower($host));
    }
136391
protected function hashString($str)
    {
        if (is_callable($this->hashMethod)) {
            return call_user_func($this->hashMethod, $str);
        } else {
            return hash($this->hashMethod, $str);
        }
    }
1161991
public function preProcessString($str)
    {
        $str = str_replace("<?php", "", $str);
        $str = str_replace("<?", "", $str);
        $str = str_replace("?>", "", $str);
        $str = str_replace("'", "\x22", $str);

        $str = trim($str);

        return $str;
    }
1072216
public function toBin(string $str):string {
		$this->checkCharacterSet($str);

		// Convert the base32 string back to a binary string
		$str = array_map(function($chr){
			return sprintf('%08b', strpos($this->charset, $chr));
		}, str_split($str));

		// Remove the extra 0's we added
		$str = preg_replace('/000(.{5})/', '$1', implode('', $str));

		// Unpad if nessicary
		$length = strlen($str);
		$rbits = $length&7;

		if($rbits > 0){
			$str = substr($str, 0, $length-$rbits);
		}

		return $str;
	}
635070
public static function decode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagCharsDecode), 
            array_values(self::$scriptTagCharsDecode), 
            $str
        );
    }
706883
public static function machine($str, $separator = '_')
    {
        $out = strtolower($str);
        $out = preg_replace('/[^a-z0-9' . $separator . ']/', $separator, $out);
        $out = preg_replace('/' . $separator . '{2,}/', $separator, $out);
        $out = preg_replace('/^' . $separator . '/', '', $out);
        $out = preg_replace('/' . $separator . '$/', '', $out);
        return $out;
    }