Get valid string length
@param   string $string Some string
@return  int
802
protected function _strlen($string)
    {
        $encoding = function_exists('mb_detect_encoding') ? mb_detect_encoding($string) : false;
        return $encoding ? mb_strlen($string, $encoding) : strlen($string);
    }
1272894
private function getLength($type = true)
    {
        if ($type) {
            $start = $this->getCharStart();
            $end = $this->getCharEnd();
        } else {
            $start = $this->getIndexStart();
            $end = $this->getIndexEnd();
        }

        if (is_null($start) && is_null($end)) {
            return;
        }

        if (!is_null($start) && is_null($end)) {
            return 1;
        }

        if ($start === $end) {
            return 1;
        }

        if ('#' === $start && '#' !== $end) {
            return $end + 1;
        }

        if ('#' !== $start && '#' === $end) {
            return;
        }

        $length = $end - $start + 1;

        if (1 > $length) {
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::NEGATIVE
            );
        }

        return $length;
    }
511333
public static function maxCharWidth($string)
    {
        $chars = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);

        if (!$chars) {
            return 0;
        }

        $sizes = array_map('strlen', $chars);

        return max($sizes);
    }
989661
public function checkLength($value)
    {
        if (strlen($value) != 8) {
            $this->setCheck(false);
        } else {
            $this->setCheck(true);
        }

        return parent::checkLength($value);
    }
484206
protected function getCorrectType($string)
    {
        if (!is_string($string)) {
            return $string;
        }

        switch (strtolower($string)) {
            case 'true':
                return true;
            case 'false':
                return false;
            case 'null':
                return null;
        }

        if (is_numeric($string)) {
            return (int)$string;
        }

        return $string;
    }
303318
public function getMaxLength()
    {
        if ($this->isString() && isset($this->methodParams[0])) {
            return intval($this->methodParams[0]);
        }

        return null;
    }
128222
protected function getLength($limit)
    {
        $size = strlen($this->data);
        if ($limit <= 0) {
            $limit += $size;
        }

        if ($limit > $size) {
            return null;
        }

        $res = (string) substr($this->data, 0, $limit);
        $this->data = (string) substr($this->data, $limit);
        return $res;
    }
245248
public static function stringToBytes(string $string): int
    {
        $original = trim($string);
        $number = (int)$original;

        if ($number === $original || $number === 0) {
            return $number;
        } else {
            $char = strtoupper(substr($original, -1, 1));
            switch ($char) {
                case 'K': // KILO
                    return $number * 1024;
                    break;

                case 'M': // MEGA
                    return $number * pow(1024, 2);
                    break;

                case 'G': // GIGA
                    return $number * pow(1024, 3);
                    break;

                case 'T': // TERA
                    return $number * pow(1024, 4);
                    break;

                case 'P': // PETA
                    return $number * pow(1024, 5);
                    break;

                case 'E': // EXA
                    return $number * pow(1024, 6);
                    break;

                default:
                    throw new ConvertException('Not implemented sizes greater than exabytes');
                    break;
            }
        }
    }
310392
public function write($string)
    {
        $this->content = substr_replace($this->content, $string, $this->position, 0);
        $len = strlen($string);
        $this->position += $len;
        return $len;
    }
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);
        }
    }
852093
public function getLength() {
		if($this->length !== null) {
			return $this->length;
		}

		$j = 0;

		foreach($this->components as $component) {
			$j += $component * $component;
		}
		return ($this->length = sqrt($j));
	}
965534
public function length($length = null)
    {
        if (!is_null($length)) {
            $this->length = (int) $length;
        }

        return $this->length;
    }
61273
public final function write($string): int
   {
       if (!$this->isWritable()) {
           throw new RuntimeException("Can't write: stream is not writable");
       }
       $this->meta["eof"] = true;
	   if (($size = (int) fwrite($this->stream, (string) $string))) {
		    $this->meta["size"] = $this->getMetadata("size") + $size;
	   }
       return $size;
   }
919175
public static function stringToKey(string $string): int {
        $key = 0;
        for ($i = 0; $i < \strlen($string); $i++) {
            $char = $string[$i];
            $key += \ord($char);
        }
        return $key;
    }
1023532
public function validate(string $string)
	{
		$validated = mb_substr($string, static::MAC_LENGTH, null, '8bit');

		if(hash_equals($this->getSignature($validated), mb_substr($string, 0, static::MAC_LENGTH, '8bit')))
		{
			return $validated;
		}

		return false;
	}
1164982
protected function evaluateDateString($string)
    {
        $seconds = 1;
        $matches = [];
        preg_match('/^([0-9]*)([s|M|h|d|m|y])$/', $string, $matches);

        switch ($matches[2]) {
            case 's':
                $seconds = $matches[1];
                break;
            case 'M':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 's');
                break;
            case 'h':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 'M');
                break;
            case 'd':
                $seconds = $this->evaluateDateString(24 * $matches[1] . 'h');
                break;
            case 'm':
                $seconds = $this->evaluateDateString(30 * $matches[1] . 'd');
                break;
            case 'y':
                $seconds = $this->evaluateDateString(12 * $matches[1] . 'm');
                break;
        }

        return $seconds;
    }
284962
protected function getPrefixLength(array $strings)
	{
		$len = 1;
		$cnt = count($strings[0]);
		while ($len < $cnt && $this->stringsMatch($strings, $len))
		{
			++$len;
		}

		return $len;
	}