コード例 #1
0
 private static function genericConstruct($cpObj = null, $class = null)
 {
     if ($cpObj == null || $class == null) {
         return null;
     }
     $isCollection = false;
     $mapper = array();
     foreach (get_object_vars($cpObj) as $key => $value) {
         if (CitrusPay_Util::isList($value)) {
             $isCollection = true;
             foreach ($value as $i) {
                 array_push($mapper, self::genericConstruct($i, $class));
             }
             break;
         }
     }
     if ($isCollection) {
         $class = $class . "Collection";
     }
     $retObj = new $class();
     foreach (get_object_vars($cpObj) as $key => $value) {
         $setterName = "set_" . $key;
         if (CitrusPay_Util::isList($value)) {
             $value = $mapper;
         }
         if (method_exists($retObj, $setterName)) {
             $retObj->{$setterName}($value);
         }
     }
     return $retObj;
 }
コード例 #2
0
 public function __toArray($recursive = false)
 {
     if ($recursive) {
         return CitrusPay_Util::convertCitrusPayObjectToArray($this->_values);
     } else {
         return $this->_values;
     }
 }