Pingpp\PingppObject::refreshFrom PHP Метод

refreshFrom() публичный Метод

Refreshes this object using the provided values.
public refreshFrom ( stdObject $values, array $opts, boolean $partial = false )
$values stdObject
$opts array
$partial boolean Defaults to false.
    public function refreshFrom($values, $opts, $partial = false)
    {
        $this->_opts = $opts;
        // Wipe old state before setting new.  This is useful for e.g. updating a
        // customer, where there is no persistent card parameter.  Mark those values
        // which don't persist as transient
        if ($partial) {
            $removed = new Util\Set();
        } else {
            $removed = array_diff(array_keys($this->_values), array_keys(get_object_vars($values)));
        }
        foreach ($removed as $k) {
            if (self::$permanentAttributes->includes($k)) {
                continue;
            }
            unset($this->{$k});
        }
        foreach ($values as $k => $v) {
            if (self::$permanentAttributes->includes($k)) {
                continue;
            }
            if (self::$nestedUpdatableAttributes->includes($k) && is_object($v)) {
                $this->_values[$k] = AttachedObject::constructFrom($v, $opts);
            } else {
                $this->_values[$k] = Util\Util::convertToPingppObject($v, $opts);
            }
            $this->_transientValues->discard($k);
            $this->_unsavedValues->discard($k);
        }
    }