/** * This method returns an array of method names for this class. * * @access public * @return array an array of method names */ public function __getMethods() { $methods = array_unique(array_merge(parent::__getMethods(), $this->methods)); return $methods; }
/** * This method maps the getter methods in the source model's translator to their corresponding setter * methods in the target model's translator. * * @access public * @static * @param \Unicity\MappingService\Data\Translator $source the model that will be the source for * the mapping * @param \Unicity\MappingService\Data\Translator $target the model that will be the target for * the mapping */ public static function map(MappingService\Data\Translator $source, MappingService\Data\Translator $target) { $source->__before(static::SOURCE_MAPPING); $target->metadata =& $source->metadata; $target->__before(static::TARGET_MAPPING); $set = 'set'; $get = 'get'; if ($source->__getClass() == $target->__getClass()) { $set = 'u' . $set; $get = 'u' . $get; } $methods = $target->__getMethods(); foreach ($methods as $method) { if (preg_match("/^{$set}[_a-zA-Z0-9]+\$/", $method)) { $getter = $get . substr($method, 3); if ($source->__hasMethod($getter)) { $target->{$method}($source->{$getter}()); } } } $target->__after(static::TARGET_MAPPING); $source->__after(static::SOURCE_MAPPING); }