Beispiel #1
0
 /**
  * @test
  */
 public function camelcase2underscore()
 {
     $result = \Ca\Core\String::camelcase2underscore('customerId');
     $this->assertEquals('customer_id', $result);
     $result = \Ca\Core\String::camelcase2underscore('HtmlElement');
     $this->assertEquals('html_element', $result);
     $result = \Ca\Core\String::camelcase2underscore('ABC');
     $this->assertEquals('a_b_c', $result);
 }
Beispiel #2
0
 /**
  * Magic method to access data via methods
  * @param string $methodname
  * @param array $args
  */
 public function __call($methodname, array $args)
 {
     $matches = array();
     preg_match('/^([a-z]+)(.*)/', $methodname, $matches);
     if (empty($matches)) {
         return null;
     }
     list($_, $method, $name) = $matches;
     array_unshift($args, CoreString::camelcase2underscore($name));
     switch ($method) {
         case 'has':
         case 'get':
         case 'set':
         case 'unset':
             return call_user_func_array(array($this, $method . 'Data'), $args);
             break;
         default:
             throw new \Exception('Unsupported method ' . $method . 'Data for index ' . $name);
     }
 }