Serialize data object to id.

@param object $data

@return int|null
436569
public function serializeObjectToId(VisitorInterface $visitor, $data, array $type, Context $context)
    {
        $className = $this->manager->getClass();

        if ($data instanceof $className) {
            return $visitor->visitInteger($data->getId(), $type, $context);
        }
    }
535982
public static function fromArray(array $data)
    {
        $result = '';
        foreach ($data as $name => $value) {
            $value = StringHelper::toString($value, "'", Serialize::SERIALIZE_JSON);
            $result .= "$name=$value; ";
        }

        return $result === '' ? null : rtrim($result);
    }
66138
public function getObjectIdentifierFromData(array $data) : array
    {
        $identifier = [];

        foreach ($this->class->getIdentifier() as $name) {
            $identifier[$name] = $data[$name];
        }

        return $identifier;
    }
183892
protected function encode($data)
    {
        if ($this->getEncoding() === self::ENCODING_BASE64) {
            return base64_encode(serialize($data));
        } else {
            return serialize($data);
        }
    }
188431
private function unserialize($data)
    {
        if ($this->type == 'db') {
            return $this->db->decode($data, $this->packed);
        }

        return $this->packed ? @unserialize($data) : $data;
    }
1131829
public function add($data = [])
    {
        $insertId = $this->db->insert($data)->into($this->table)->execute(FALSE);

        return $insertId;
    }
1120188
protected function parseDataForModelFindParams($data)
    {
        if ( ! is_array($data) || ! isset($data['id']) || empty($data['id'])) {
            return false;
        }

        return intval($data['id']);
    }
20883
public function reverseTransform($data)
    {
        if (is_array($data)) {
            $id = current($data);
            $document = $this->objectManager->find($this->documentClass, $id);

            return $this->entityDbMapper->fromEntityToDb($document);
        }

        return null;
    }
850243
public function redislize($data)
    {
        // Only serialize if it's not a string or a integer
        if (!is_string($data) && !is_int($data)) {
            return urlencode(serialize($data));
        }
        // Encode string to escape wrong saves
        return urlencode($data);
    }
894845
public function save($data)
    {
        if (!isset($data[$this->primaryKey])) {
            $data[$this->primaryKey] = 0;
        }

        try {
            if (0 === $data[$this->primaryKey]) {
                unset($data[$this->primaryKey]);

                $id = $this->insert($data);
            } else {
                if ($this->find($data[$this->primaryKey], true)) {
                    $this->update($data);
                } else {
                    $this->insert($data);
                }

                $id = $data[$this->primaryKey];
            }
        } catch(\Exception $e) {
            return [
                'code' => $e->getCode(),
                'message' => $e->getMessage()
            ];
        }

        return $id;
    }
985337
protected function serializeItem($data) {
        if ($data instanceof IArrayable) {
            return $data->toArray();
        } else if ($data instanceof IJsonable) {
            return $data->toJson();
        } else if ($data instanceof IStringable) {
            return $data->toString();
        }

        return $data;
    }
90976
protected function update($data)
    {
        try {

            if ($this->updateTouch) {
                $data[$this->updateTouchName] = date('Y-m-d H:i:s');
            }

            $this->db->update(
                $this->table,
                $this->fromArray($data),
                [
                    $this->primaryKey => $data[$this->primaryKey]
                ]
            );

            $id = $data[$this->primaryKey];

        } catch (\Exception $e) {
            throw $e;
        }

        return $id;
    }
1159660
private function convertToJson($data)
    {
        if (is_array($data)) {
            return json_encode($data);
        }

        if ($data instanceof Jsonable) {
            return $data->toJson();
        }

        if ($data instanceof Arrayable) {
            return json_encode($data->toArray());
        }

        return null;
    }
647881
protected function unserializeData($data)
    {
        $value = null;
        // if we're not deserialised yet, do so
        if (is_string($data) && strlen($data) > 1) {
            // are we json encoded?
            if ($data{1} === ':') {
                $value = \unserialize($data);
            } else {
                $value = \json_decode($data, true);
            }
        }
        return $value;
    }
680979
private function serialize($data)
    {
        if ($this->type == 'db') {
            return $this->db->encode($data, $this->packed);
        }

        return $this->packed ? serialize($data) : $data;
    }
503879
public static function unserialize ($data) {
		foreach (unserialize($data) ?? [] as $name => $datum) {
			static::$multitonInstances[$name] = unserialize($datum);
		}
	}
1200979
public function assignData($data)
    {
        $storeId = $this->getInfoInstance()->getQuote()->getStoreId();
        $details = array();

        if ($this->getAccountName()) {
            $details['account_name'] = $this->getAccountName($storeId);
        }

        if ($this->getAccountBSB()) {
            $details['account_bsb'] = $this->getAccountBSB($storeId);
        }

        if ($this->getAccountNumber()) {
            $details['account_number'] = $this->getAccountNumber($storeId);
        }

        if ($this->getMessage()) {
            $details['message'] = $this->getMessage($storeId);
        }

        if (!empty($details)) {
            $this->getInfoInstance()->setAdditionalData(serialize($details));
        }

        return $this;
    }