Exemplo n.º 1
0
 public function testJoinPostPre()
 {
     $sj = new StringJoiner("Delim", "Pre", "Post");
     $sj->add("_String_");
     $sj->add("_Second_");
     $this->assertEquals("Pre_String_Delim_Second_Post", $sj->toString()->getOriginalValue());
 }
Exemplo n.º 2
0
Arquivo: String.php Projeto: phpj/phpj
 /**
  * Returns a new String composed of copies of the
  * {@code CharSequence elements} joined together with a copy of
  * the specified {@code delimiter}.
  *
  * <blockquote>For example,
  * <pre>{@code
  *     String message = String.join("-", "Java", "is", "cool");
  *     // message returned is: "Java-is-cool"
  * }</pre></blockquote>
  *
  * Note that if an element is null, then {@code "null"} is added.
  *
  * @param  string|\PHPJ\Lang\String $delimiter
  *         the delimiter that separates each element
  *
  * @return \PHPJ\Lang\String
  *         a new {@code String} that is composed of the {@code elements}
  *         separated by the {@code delimiter}
  *
  * @throws NullPointerException If {@code delimiter} or {@code elements}
  *         is {@code null}
  *
  * @see java.util.StringJoiner
  * @since 1.8
  */
 public static function join($delimiter)
 {
     $sequence = self::joinGetSequence(func_get_args());
     $sj = new StringJoiner((string) $delimiter);
     foreach ($sequence as $cs) {
         $sj->add($cs);
     }
     return $sj->toString();
 }