Example #1
0
 /**
  * @dataProvider camelCaseValues
  */
 public function testCamelCaseWorks($s)
 {
     $ts = new \NG\Root\Type\TString($s);
     $cC = $ts->toCamelCase();
     //echo $s . " => " . $cC->value();
     $this->assertTrue($cC instanceof \NG\Root\Type\TString);
     $res = preg_match('/^\\s*([a-z0-9]+)(([A-Z]{1}[a-z0-9]*)+)/', $cC->value());
     //var_dump($cC->value());
     $this->assertTrue($res);
 }
Example #2
0
 /**
  * Converts the value to camel-case format
  * @param php string $separator
  * @return php string
  */
 public function toCamelCase($separator = ' ')
 {
     $complete = '';
     $parts = $this->explode($separator);
     foreach ($parts->value() as $key => $part) {
         $part = new \NG\Root\Type\TString($part);
         if ($key == 0) {
             $complete = $part->toLowerCase()->value();
         } else {
             $complete .= $part->ucfirst()->value();
         }
     }
     $cut = new \NG\Root\Type\TString($complete);
     return $cut->cut(1, $cut->length() - 1);
 }