示例#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();
 }
示例#2
0
文件: StringTest.php 项目: phpj/phpj
 /**
  * @dataProvider dataGetChars
  */
 public function testGetChars($srcBegin, $srcEnd, $dst, $dstBegin, $expected)
 {
     $dstReturn = $this->string->getCharsFromTo($srcBegin, $srcEnd, $dst, $dstBegin);
     $this->assertEquals($expected, (string) $dst);
     $this->assertEquals($expected, (string) $dstReturn);
 }