/** * 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(); }
/** * @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); }