Exemplo n.º 1
0
 public function __call($method, $arguments)
 {
     $this->checkWhetherRecordOperateable();
     if (strpos($method, 'init_') === 0) {
         $relationship = ltrim($method, 'init_');
         $relationshipMetadata = $this->relationship->getMetadata($relationship);
         if ($relationshipMetadata === null) {
             $relationship = Helper::pluralize($relationship);
             $relationshipMetadata = $this->relationship->getMetadata($relationship);
             if ($relationship === null) {
                 throw new UndefinedMethodException($method, get_called_class());
             }
         }
         $this->{$relationship} = new $relationshipMetadata['class']($arguments[0]);
         return true;
     }
     if (preg_match('/_was_changed$/', $method)) {
         $attribute = preg_replace('/_was_changed$/', '', $method);
         if (array_key_exists($attribute, $this->_attributes)) {
             return array_key_exists($attribute, $this->_changedAttributes);
         }
     }
     throw new UndefinedMethodException($method, get_called_class());
 }
Exemplo n.º 2
0
 public function testPluralize()
 {
     $this->assertEquals('Users', Helper::pluralize('User'));
 }