@param string  $value
@param integer $length

@return bool
338843
public static function hasLength($value, $length)
    {
        \settype($length, 'int');

        return \mb_strlen($value, \mb_detect_encoding($value)) === $length;
    }
1001440
public static function length($value, $min = null, $max = null)
    {
        $length = mb_strlen($value);

        if (is_numeric($min) && $min > 0 && $length < $min) {
            return false;
        }

        if (is_numeric($max) && $max > 0 && $length > $max) {
            return false;
        }

        return true;
    }
115815
public function length($length, $error) {
        if ($this->_exist) {
            array_push($this->_constraints, ['type' => self::LENGTH, 'value' => $length, 'message' => $error]);
        }

        return $this;
    }
546316
public function isValid($value) {
		if (! is_string($value)) {
			$this->addMessage('Value must be a string');
		
			return false;
		}
		
		if ($this->lengthMin !== null && $this->lengthMax !== null && $this->lengthMin >= $this->lengthMax) {
			throw new ValidationFailure('Min length cannot be equal or greater than max length');
		}
		
		if ($this->encoding === null) {
			$length = mb_strlen($value);
		} else {
			$length = mb_strlen($value, $this->encoding);
		}
		
		if ($this->lengthMin !== null && $length < $this->lengthMin) {
			$this->addMessage('Must be not less than %s symbols', $this->lengthMin);
		
			return false;
		}
		
		if ($this->lengthMax !== null && $length > $this->lengthMax) {
			$this->addMessage('Must be not more than %s symbols', $this->lengthMax);
		
			return false;
		}
		
		return true;
	}
903314
protected function isAcceptLength($value)
    {
        $value = strlen(utf8_decode($value));

        if ($value < $this->min) {
            throw new ExceptionFactory('InvalidLength', [$value, 'greater', $this->min]);
        }
        else if ($value > $this->max) {
            throw new ExceptionFactory('InvalidLength', [$value, 'less', $this->max]);
        }

        return true;
    }
424228
public static function fixStringLength($value, $length, $endChars = '...')
    {
        if (!empty($value) and !empty($length)) {
            $cutLen = (int) $length - (int) strlen($endChars);
            if (strlen($value) > $length) {
                $strCut = substr($value, 0, $cutLen);
                $value = $strCut . $endChars;
            }
        }
        return $value;
    }
988973
public static function minLength($value, int $minLength, string $encoding = 'UTF-8'): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        $strlen = (int) mb_strlen((string) $value, $encoding);

        return $strlen >= $minLength;
    }
682896
public function str($value, $minLength = 0, $maxLength = false, $default = false)
	{
		$value = trim($value);
		if ((!empty($minLength) && (mb_strlen($value, $this->encoding) < $minLength)) ||
			(!empty($maxLength) && (mb_strlen($value, $this->encoding) > $maxLength))
		) {
			return $default;
		}

		return (string) $value;
	}
589789
protected static function checkBasic($data, $length): bool
    {
        return $length < 4 || $data[1] !== ':' || ($data[$length - 1] !== ';' && $data[$length - 1] !== '}');
    }
231642
public function transform(string $value, int $start = 0, int $length = null): string {
        return $length === null ? substr($value, $start) : substr($value, $start, $length);
    }
251389
public static function minLength($value, $param)
    {
        $length = is_array($value) ? count($value) : mb_strlen($value);

        return $length >= $param;
    }
1226995
public static function pad($value, $length = 5, $prfx = 0)
	{
		$pre = '';

		if (is_numeric($value) && $value < 0)
		{
			$pre = 'n';
			$value = abs($value);
		}

		while (strlen($value) < $length)
		{
			$value = $prfx . "$value";
		}
		return $pre . $value;
	}
1274164
protected function _exportParamValue($value = null, $length = 0) {
		$truncateOpt = [
			'ellipsis' => '...',
			'exact' => false,
			'html' => false
		];

		$valueText = var_export($value, true);
		$valueType = Debugger::getType($value);
		switch ($valueType) {
			case 'string':
				if (ctype_digit($value)) {
					$valueText = (int)$value;
				}
				break;
			case 'resource':
			case 'unknown':
				$valueText = 'null';
				break;
		}
		if ($length > 0) {
			$valueText = CakeText::truncate($valueText, $length, $truncateOpt);
		}

		return $valueText;
	}
54759
public static function length(string $value, int $min, int $max):bool
    {
        $value = (string)$value;
        $length = Str::length($value);
        return $length >= $min && $length <= $max;
    }
1105393
public function fgets( $length = null )
    {
        return $this->validHandle() ? fgets( $this->_fileHandle, $length ) : false;
    }
1113111
public static function exactLength($value, $length)
    {
        if ( ! is_array($length))
        {
            $length = [$length];
        }

        foreach ($length as $strlen)
        {
            if (strlen($value) === $strlen)
            {
                return true;
            }
        }

        return false;
    }
782980
public function read($length)
    {
        if ($this->offset == $this->array_size) {
            return false;
        }

        // Don't use array slice
        $arrays = [];
        $end = $length + $this->offset;
        for ($i = $this->offset; $i < $end; ++$i) {
            if (!isset($this->array[$i])) {
                break;
            }
            $arrays[] = $this->array[$i];
        }
        $this->offset += $i - $this->offset; // Limit function calls
        $chars = false;
        foreach ($arrays as $array) {
            $chars .= implode('', array_map('chr', $array));
        }

        return $chars;
    }