Exemple #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);
 }
Exemple #2
0
 public function testFrom()
 {
     $array = CharArray::fromString('str');
     $this->assertInstanceOf($this->getClassName(), $array);
     $this->assertEquals('str', (string) $array);
 }
Exemple #3
0
 /**
  * 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);
     });
 }
Exemple #4
0
 /**
  * @param $str
  * @return CharArray
  */
 protected function processStr($str)
 {
     if ($str instanceof CharArray) {
         return $str;
     }
     if (null === $str) {
         $str = 'null';
     }
     if (is_bool($str)) {
         $str = $str ? 'true' : 'false';
     }
     return CharArray::fromString($str);
 }