Exemple #1
0
 /**
  * Returns the length of the {@code String} representation
  * of this {@code StringJoiner}. Note that if
  * no add methods have been called, then the length of the {@code String}
  * representation (either {@code prefix + suffix} or {@code emptyValue})
  * will be returned. The value should be equivalent to
  * {@code toString().length()}.
  *
  * @return int
  *         the length of the current value of {@code StringJoiner}
  */
 public function length()
 {
     // Remember that we never actually append the suffix unless we return
     // the full (present) value or some sub-string or length of it, so that
     // we can add on more if we need to.
     return $this->value !== null ? $this->value->length() + $this->suffix->length() : $this->emptyValue->length();
 }
Exemple #2
0
 public function testSetCharAt()
 {
     $sb = new StringBuilder();
     $sb->append('This');
     $sb->setCharAt(2, 'u');
     $this->assertEquals('Thus', (string) $sb);
 }