row = $instance; } else { $this->row = SerializerObject::instance($instance)->serialize(); } $this->acceptChanges(); } /** * Add a string field to row * @param string $name * @param string|array|null $value * @return void */ public function addField($name, $value) { $name = $this->getHydratedFieldName($name); if (!array_key_exists($name, $this->row)) { $this->row[$name] = $value; } elseif (is_array($this->row[$name])) { $this->row[$name][] = $value; } else { $this->row[$name] = array($this->row[$name], $value); } } /** * @param string $name - Field name * @return null|string * @desc et the string value from a field name */ public function get($name) { $name = $this->getHydratedFieldName($name); if (!array_key_exists($name, $this->row)) { return null; } $result = $this->row[$name]; if (is_array($result)) { return array_shift($result); } else { return $result; } } /** * Get array from a single field * * @param string $fieldName * @return array */ public function getAsArray($fieldName) { $fieldName = $this->getHydratedFieldName($fieldName); if (!array_key_exists($fieldName, $this->row)) { return []; } $result = $this->row[$fieldName]; if (empty($result)) { return []; } return (array)$result; } /** * Return all Field Names from current Row * @return array */ public function getFieldNames() { return array_keys($this->row); } /** * Set a string value to existing field name * @param string $name * @param string $value * @return void */ public function set($name, $value) { $name = $this->getHydratedFieldName($name); if (!array_key_exists($name, $this->row)) { $this->addField($name, $value); } else { $this->row[$name] = $value; } } /** * Remove specified field name from row. * * @param string $fieldName * @return null */ public function removeField($fieldName) { $fieldName = $this->getHydratedFieldName($fieldName); if (array_key_exists($fieldName, $this->row)) { unset($this->row[$fieldName]); } } /** * Remove specified field name with specified value name from row. * * @param string $fieldName * @param mixed $value * @return void */ public function removeValue($fieldName, $value) { $fieldName = $this->getHydratedFieldName($fieldName); $result = $this->row[$fieldName]; if (!is_array($result)) { if ($value == $result) { unset($this->row[$fieldName]); } } else { $qty = count($result); for ($i = 0; $i < $qty; $i++) { if ($result[$i] == $value) { unset($result[$i]); } } $this->row[$fieldName] = array_values($result); } } /** * Update a specific field and specific value with new value * * @param String $fieldName * @param String $oldvalue * @param String $newvalue * @return void */ public function replaceValue($fieldName, $oldvalue, $newvalue) { $fieldName = $this->getHydratedFieldName($fieldName); $result = $this->row[$fieldName]; if (!is_array($result)) { if ($oldvalue == $result) { $this->row[$fieldName] = $newvalue; } } else { for ($i = count($result) - 1; $i >= 0; $i--) { if ($result[$i] == $oldvalue) { $this->row[$fieldName][$i] = $newvalue; } } } } /** * @param array|null $fields * @return array */ public function toArray($fields = []) { if (empty($fields)) { return $this->row; } $fieldAssoc = array_combine($fields, array_fill(0, count($fields), null)); return array_intersect_key(array_merge($fieldAssoc, $this->row), $fieldAssoc); } /** * @return array */ public function getAsRaw() { return $this->originalRow; } /** * @return bool */ public function hasChanges() { return ($this->row != $this->originalRow); } /** * @return void */ public function acceptChanges() { $this->originalRow = $this->row; } /** * @return void */ public function rejectChanges() { $this->row = $this->originalRow; } /** * Override Specific implementation of setPropValue to Row * * @param Row $obj * @param string $propName * @param string $value * @return void */ protected function setPropValue($obj, $propName, $value) { $obj->set($propName, $value); } /** * @param string $name * @return bool */ public function fieldExists($name) { return isset($this->row[$this->getHydratedFieldName($name)]); } /** * @return void */ public function enableFieldNameCaseInSensitive() { $this->row = array_change_key_case($this->row, CASE_LOWER); $this->originalRow = array_change_key_case($this->originalRow, CASE_LOWER); $this->fieldNameCaseSensitive = false; } /** * @return bool */ public function isFieldNameCaseSensitive() { return $this->fieldNameCaseSensitive; } /** * @param string $name * @return string */ protected function getHydratedFieldName($name) { if (!$this->isFieldNameCaseSensitive()) { return strtolower($name); } return $name; } }__halt_compiler();----SIGNATURE:----z8Q3bLqzxyZ72GxHmkORmX0CVLojwjjiGRgU8iI0EAVDNVtDIFRHokIqWLeDDj4oQZceqgMGaU3f30xQA2vOZFLePPGf9G7HFIe73Aki6aHzU5PzuN6V+6x/TRjZwS+0M5B2B/bGG59/wGK5ZTPbiNhGZjxTxZfXuzWddyeZQuGlPt1YmIaD7lDkXfiOJ0T5Yr+PAtAeNYSiYK6GB3ko8OTcPXI4crRuQOz4twaOH6hdy+SW6UX05iJtJb8htZbRpEUyxFwDcapGhf17EosgSkTq5wvFtNz+glZ4XFMcXAQAh0b9ZstMKR/CjuZhjWtXIQrjQ2d3z2+C31T2d7vJIJJvcEKI0OJUsCkdodAQXYWp9TGCKcqyHJIi+zyHKc0WfkVdoqKOQNTSkMImxrUv65uIYme8YK3AggMsDPzZ0KQrSvuojzzHMjhKgXWBzu5FUTIOZ883aTvCJEhFPs7c0YLjA5MloIhbeqBZJLZfhTdSpIpfWIL4T+WJpOgFy9TIU97Rd9QIBCtuF2uAKt0c9YXJSFoUmV3A9FRTG79yEGXJi7GroTIZkQpCNs9akjZ6Qp530EYbBZcbXD69BFC1gfw6Z4I1eGKbtxyuVbCbc4RPFnfhv2IIlS07cu4YlX48DzKSmuT+Jtt2TawYN5t6g+zdQseITjvy4aipV6VHN3U=----ATTACHMENT:----MTY0MTYyMTg1MjYzNTY5NyA3ODAxMzkxNTQzODM2Njk2IDk3NDQ1Mzc3MjU0MjA2NTQ=