Exemple #1
0
 /**
  * This method attempts to call the specified getter/setter.
  *
  * @access public
  * @param string $method                                    the name of the method to be
  *                                                          called
  * @param array $args                                       the arguments passed
  * @return mixed                                            the result of the method
  */
 public function __call($method, $args)
 {
     if (preg_match('/^get[_a-zA-Z0-9]+$/', $method)) {
         $properties = preg_split('/_+/', substr($method, 3));
         $key = null;
         $value = $this->models;
         foreach ($properties as $property) {
             $key = $property;
             if (!property_exists($value, $key)) {
                 return null;
             }
             $value = $value->{$key};
         }
         $field = new MappingService\Data\Field(MappingService\Data\FormatType::canonical());
         if (is_object($value)) {
             $properties = get_object_vars($value);
             foreach ($properties as $key => $value) {
                 $field->putItem($key, $value);
             }
         } else {
             $field->putItem($key, $value);
         }
         return $field;
     }
     return null;
 }
Exemple #2
0
 /**
  * This method returns the data in the canonical format and will handle the transformation
  * if necessary.
  *
  * @access public
  * @return \Unicity\MappingService\Data\Field               the data in the canonical format
  */
 public function toCanonicalFormat()
 {
     $field = new MappingService\Data\Field(MappingService\Data\FormatType::canonical(), $this->field);
     $field->setInfo($this->field->getInfo());
     return $field;
 }