lib/Assertion.php
function lengthOf(int $value = null): self {
    if ($value === null) return $this->setFlag('length');

    if (is_string($this->target)) {
      $constraint = equalTo($value);
      $target = mb_strlen($this->target);
    }
    else {
      $constraint = countOf($value);
      $target = $this->target;
    }

    return $this->expect($target, $constraint);
  }
function lengthOf(int $value = null): self {
    if ($value === null) return $this->setFlag('length');

    if (is_string($this->target)) {
      $constraint = equalTo($value);
      $target = mb_strlen($this->target);
    }
    else {
      $constraint = countOf($value);
      $target = $this->target;
    }

    return $this->expect($target, $constraint);
  }
Reports an error if the length of the target is not the expected one.
@param int $value The expected length.
@return self This instance.