public function unserialize($string)
    {
        $data = json_decode($string);
        foreach ($data as $property => $value) {
            $method = $this->setterName($property);

            if (is_numeric($value) && strstr($value, '.')) {
                $value = floatval($value);
            } elseif (is_object($value)) {
                if ($property == 'authorization_information') {
                    $object = new AuthorizationInformation();
                    $object->unserialize(json_encode($value));
                    $value = $object;
                } elseif ($property == 'payment_instrument') {
                    if (!isset($data->payment_method)) {
                        throw new Exception\Runtime('Property "payment_method" is missing');
                    }

                    switch ($data->payment_method) {
                        case Payment\Create::CARD:
                            $object = new PaymentInstrumentCard();
                            break;
                        case Payment\Create::RECURRING:
                            $object = new PaymentInstrumentRecurring();
                            break;
                        default:
                            $object = new PaymentInstrumentCard();
                            break;
                    }
                    $object->unserialize(json_encode($value));
                    $value = $object;
                }
            }

            $this->$method($value);
        }
    }
public function unserialize($string)
    {
        $data = json_decode($string);
        foreach ($data as $property => $value) {
            $method = $this->setterName($property);

            if (is_numeric($value) && strstr($value, '.')) {
                $value = floatval($value);
            } elseif (is_object($value)) {
                if ($property == 'authorization_information') {
                    $object = new AuthorizationInformation();
                    $object->unserialize(json_encode($value));
                    $value = $object;
                } elseif ($property == 'payment_instrument') {
                    if (!isset($data->payment_method)) {
                        throw new Exception\Runtime('Property "payment_method" is missing');
                    }

                    switch ($data->payment_method) {
                        case Payment\Create::CARD:
                            $object = new PaymentInstrumentCard();
                            break;
                        case Payment\Create::RECURRING:
                            $object = new PaymentInstrumentRecurring();
                            break;
                        default:
                            $object = new PaymentInstrumentCard();
                            break;
                    }
                    $object->unserialize(json_encode($value));
                    $value = $object;
                }
            }

            $this->$method($value);
        }
    }
public function unserialize ( $ string ) { $ data = json_decode ( $ string ) ; foreach ( $ data as $ property => $ value ) { $ method = $ this -> setterName ( $ property ) ; if ( is_numeric ( $ value ) && strstr ( $ value , '.' ) ) { $ value = floatval ( $ value ) ; } elseif ( is_object ( $ value ) ) { if ( $ property == 'authorization_information' ) { $ object = new AuthorizationInformation ( ) ; $ object -> unserialize ( json_encode ( $ value ) ) ; $ value = $ object ; } elseif ( $ property == 'payment_instrument' ) { if ( ! isset ( $ data -> payment_method ) ) { throw new Exception \ Runtime ( 'Property "payment_method" is missing' ) ; } switch ( $ data -> payment_method ) { case Payment \ Create :: CARD : $ object = new PaymentInstrumentCard ( ) ; break ; case Payment \ Create :: RECURRING : $ object = new PaymentInstrumentRecurring ( ) ; break ; default : $ object = new PaymentInstrumentCard ( ) ; break ; } $ object -> unserialize ( json_encode ( $ value ) ) ; $ value = $ object ; } } $ this -> $ method ( $ value ) ; } }
Loads result object values from json object
@param string $string json
@return void
Loads result object values from json object