Perform a length assertion.

@param string|array|Countable $countable
@param $length
@param string $message
11696
public function lengthOf($countable, $length, $message = '')
    {
        $this->assertion->setActual($countable);

        return $this->assertion->to->have->length($length, $message);
    }
1024629
public function assertIsStringAndNonEmpty($value, $message='%s must be a string and not empty', $exception='Asserts')
    {
        if (is_string($value) === false || strlen($value) < 1) {
            $this->throwException($exception, $message, $value);
        }
    }
135844
function(a, length, allowNumbers, msg) {
    allowNumbers = allowNumbers || true;
    return assert((this.assertIsString(a, allowNumbers) && a.length <= length), msg);
  }
1094313
public function validate(Message $message)
    {
        if ($message->getTitleLength() > self::CHARACTER_LIMIT) {
            $message->addStatus(new LimitTheTitleLengthTo69CharactersStatus());
        }
    }
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;
    }
797250
public static function exactLength($value, int $length, string $encoding = 'UTF-8'): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

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

        return $strlen === $length;
    }
1114878
public function translate($message, $count = null)
	{
		return isset($this->dictionary[$message]) ? $this->dictionary[$message] : $message;
	}
277422
private static function preserveBreakpoint($value, $length)
    {
        if (strlen($value) <= $length) {
            return $length;
        }
        $breakpoint = mb_strpos($value, ' ', $length);
        $length = $breakpoint;
        if (false === $breakpoint) {
            $length = mb_strlen($value);
        }
        return $length;
    }
1086060
private static function isWhitespaceOfLength(TokenInterface $token, int $length): bool
    {
        return static::isWhitespace($token) && strlen(trim($token->getValue(), "\n")) == $length;
    }
792574
public final function setContentLength($length)
    {
        if (! is_numeric($length)) {

            throw new
                ehough_shortstop_api_exception_InvalidArgumentException("Content-Length must be an integer ($length)");
        }

        $length = intval($length);

        if ($length < 0) {

            throw new
                ehough_shortstop_api_exception_InvalidArgumentException("Content-Length cannot be negative ($length)");
        }

        $this->_contentLength = $length;
    }
1193631
public static function assertStringIsEmpty($actual, string $message = '')
    {
        AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsEmpty', ['assertThat', 'assertEmpty']);
        self::assertThat($actual, new IsType('string'), $message);
        self::assertEmpty($actual, $message);
    }
147601
final public function socketWrite($message = '', $length = null)
	{
		return @socket_write(
			$this->socket,
			"{$message}",
			is_int($length) ? $length : strlen($message)
		);
	}
454209
private static void assertArrayLength(final int length, final JBBPNamedFieldInfo name) {
    if (length < 0) {
      throw new JBBPParsingException("Detected negative calculated array length for field '" + (name == null ? "<NO NAME>" : name.getFieldPath()) + "\' [" + JBBPUtils.int2msg(length) + ']');
    }
  }
160556
public static function getRandomPassword($length = null, $countCharsNum = null, $countCharsSpecial = null)
    {
        $chars = [
            'alpha'   => 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ',
            'special' => '!$%&=?*-:;.,+~@_',
        ];

        if (null === $length) {
            $length = mt_rand(9, 13);
        }

        if (null === $countCharsNum) {
            $countCharsNum = mt_rand(2, 3);
        }

        if (null === $countCharsSpecial) {
            $countCharsSpecial = mt_rand(1, 2);
        }

        $countCharsAlpha = $length - $countCharsNum - $countCharsSpecial;
        if (0 >= $countCharsAlpha) {
            throw new \LogicException(sprintf('%d chars are not enough to include %d numbers and %d special chars', $lengthAlpha, $countCharsNum, $countCharsSpecial));
        }

        $result = [];

        for ($index = 0; $index < $countCharsAlpha; $index++) {
            $result[] = substr($chars['alpha'], mt_rand(0, 45), 1);
        }

        for ($index = 0; $index < $countCharsNum; $index++) {
            $result[] = mt_rand(1, 9);
        }

        for ($index = 0; $index < $countCharsSpecial; $index++) {
            $result[] = substr($chars['special'], mt_rand(0, 15), 1);
        }

        shuffle($result);

        return join('', $result);
    }
803712
public static void hasSize(Collection<?> input, int length, String message) {

    notNull(input, message);
    if (input.size() != length) {
      throw new IllegalArgumentException(message);
    }
  }
719313
public function record(EventMessage $message): void
    {
        $eventRecord = new EventRecord(
            $message,
            $this->aggregateId,
            $this->aggregateType,
            $this->nextSequence()
        );
        $this->lastSequence = $eventRecord->sequenceNumber();
        $this->eventRecords->add($eventRecord);
    }
715432
public function throwError($msg = 'parse error', $count = null)
    {
        $count = is_null($count) ? $this->count : $count;

        $line = $this->line +
            substr_count(substr($this->buffer, 0, $count), "\n");

        if (!empty($this->sourceName)) {
            $loc = "$this->sourceName on line $line";
        } else {
            $loc = "line: $line";
        }

        // TODO this depends on $this->count
        if ($this->peek("(.*?)(\n|$)", $m, $count)) {
            throw new exception("$msg: failed at `$m[1]` $loc");
        } else {
            throw new exception("$msg: $loc");
        }
    }