Determine if we should use mb_strlen or stock strlen.

@param string $value The string value to check

@return int Size of string

@see MHlavac\Gearman\Connection::$multiByteSupport
344194
public static function stringLength($value)
    {
        if (is_null(self::$multiByteSupport)) {
            self::$multiByteSupport = intval(ini_get('mbstring.func_overload'));
        }

        if (self::$multiByteSupport & 2) {
            return mb_strlen($value, '8bit');
        } else {
            return strlen($value);
        }
    }
176928
public static function utf8($value)
    {
        if (is_string($value) && mb_detect_encoding($value, "UTF-8", TRUE) != "UTF-8") {
            return utf8_encode($value);
        } else {
            return $value;
        }
    }
772681
protected function intToBinary($value)
    {
        $nbytes = 0;
        if ($value > 0xFF) {
            $nbytes = 1; // 1 byte integer
        }
        if ($value > 0xFFFF) {
            $nbytes += 1; // 4 byte integer
        }
        if ($value > 0xFFFFFFFF) {
            $nbytes += 1; // 8 byte integer
        }
        if ($value < 0) {
            $nbytes = 3; // 8 byte integer, since signed
        }

        $bdata = self::typeBytes("1", $nbytes); // 1 is 0001, type indicator for integer
        $buff = "";

        if ($nbytes < 3) {
            if ($nbytes == 0) {
                $fmt = "C";
            } elseif ($nbytes == 1) {
                $fmt = "n";
            } else {
                $fmt = "N";
            }

            $buff = pack($fmt, $value);
        } else {
            if (PHP_INT_SIZE > 4) {
              // 64 bit signed integer; we need the higher and the lower 32 bit of the value
                $high_word = $value >> 32;
                $low_word = $value & 0xFFFFFFFF;
            } else {
                // since PHP can only handle 32bit signed, we can only get 32bit signed values at this point - values above 0x7FFFFFFF are
                // floats. So we ignore the existance of 64bit on non-64bit-machines
                if ($value < 0) {
                    $high_word = 0xFFFFFFFF;
                } else {
                    $high_word = 0;
                }
                $low_word = $value;
            }
            $buff = pack("N", $high_word).pack("N", $low_word);
        }

        return $bdata.$buff;
    }
1065489
public static function len($string): int
    {
        if (self::isMBString()) {
            return mb_strlen($string, self::$encoding);
        }

        return strlen($string); // @codeCoverageIgnore
    }
771086
public function string($value)
    {
        if ($this->notBeEmpty($value)) {
            if (is_string($value) && preg_match('/[A-Za-z]+/i', $value)) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
338843
public static function hasLength($value, $length)
    {
        \settype($length, 'int');

        return \mb_strlen($value, \mb_detect_encoding($value)) === $length;
    }
320251
protected function convertToBytes($value)
    {
        $value = trim($value);
        $last  = strtolower($value[strlen($value) - 1]);

        switch ($last) {
            // The 'G' modifier is available since PHP 5.1.0
            case 'g':
                $value *= 1024;
                break;

            case 'm':
                $value *= 1024;
                break;

            case 'k':
                $value *= 1024;
                break;
        }

        return $value;
    }
276343
protected function stringToBytes(string $str): int
    {
        $str = strtoupper(trim($str));

        $value = substr($str, 0, -1);
        $unit = substr($str, -1);
        switch ($unit) {
            case self::GIGABYTES:
                $value *= 1024;
            case self::MEGABYTES:
                $value *= 1024;
            case self::KILOBYTES:
                $value *= 1024;
        }

        return (int) $value;
    }
60488
public function marshal($value)
    {
        if ($value === null || $value === '') {
            return null;
        }
        if (is_numeric($value)) {
            return (int)$value;
        }

        return null;
    }
973342
public static function length($str)
    {
        if (empty($str)) {
            return '0';
        }

        if ((string)$str === '0') {
            return '1';
        }

        if (\function_exists('mb_strlen')) {
            return mb_strlen($str, 'utf-8');
        }

        preg_match_all('/./u', $str, $arr);

        return \count($arr[0]);
    }
1248102
protected function validateValueSize($value){

		// Serialize the value being saved to get a byte-stream string.
		// Strlen returns number of bytes in a string.
		$size = strlen(serialize($value));

		// The limit for values is 4 MB.
		$allowed = 1024 * 1024 * 4;
		if($size > $allowed){

			return false;
		}

		return true;
	}
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
815302
public static function stringOrInteger($value)
    {
        if (!is_string($value) and !is_int($value)) {
            $message = sprintf('Value "%s" expected to be string or integer, type %s given.', static::stringify($value), gettype($value));

            throw static::createException($value, $message, static::INVALID_STRING_INTEGER, null);
        }
    }
823145
public function validateString()
    {
        $len = function_exists('mb_strlen') ? mb_strlen($this->getValue()) : strlen($this->getValue());

        return $len >= $this->getArg(0) && $len <= $this->getArg(1);
    }
360419
final protected function valueInBounds($value)
    {
        return is_null($value) || (
            (is_null($this->getMinLength()) || strlen($value) >= $this->getMinLength())
            &&
            (is_null($this->getMaxLength()) || strlen($value) <= $this->getMaxLength())
        );
    }
134477
public static function maxLength($value, $param)
    {
        $length = is_array($value) ? count($value) : mb_strlen($value);

        return $length <= $param;
    }
1257292
public static function lengths($value, $length)
    {
        if (is_array($length)) {
            foreach ($length as $strlen) {
                if (mb_strlen($value) === $strlen) {
                    return true;
                }
            }

            return false;
        }

        return mb_strlen($value) === $length;
    }