Example #1
1
 public function testCopy2()
 {
     $str = CharArray::fromString("Test");
     $str->setSize(5);
     $res = System::arraycopy($str, 1, $str, 2, 3);
     $this->assertEquals("Teest", (string) $res);
 }
Example #2
0
 public function testOffsetSet()
 {
     $chars = new CharArray(16);
     $chars[0] = 'o';
     $chars[1] = 'ß';
     $this->assertEquals('oß', $chars->toString()->getOriginalValue());
     $this->assertEquals('oß', (string) $chars);
 }
Example #3
0
File: String.php Project: phpj/phpj
 /**
  * Converts this string to a new character array.
  *
  * @return  CharArray a newly allocated character array whose length is the length
  *          of this string and whose contents are initialized to contain
  *          the character sequence represented by this string.
  */
 public function toCharArray()
 {
     return Option::fromValue($this->charArray)->getOrCall(function () {
         return $this->charArray = CharArray::fromString($this->value);
     });
 }
Example #4
0
 /**
  * @return  \PHPJ\Lang\String - a string consisting of exactly this sequence of characters
  */
 public function toString()
 {
     return $this->length() ? new String($this->value->toString()) : new String();
 }