/** * Set a specific key to a value in the settings data. * * @param string|array $key Key string or associative array of key => value * @param mixed $value Optional only if the first argument is an array */ public function set($key, $value = null) { $this->checkLoaded(); $this->unsaved = true; if (is_array($key)) { foreach ($key as $k => $v) { Arr::set($this->data, $k, $v); } } else { Arr::set($this->data, $key, $value); } }
/** * Parse data coming from the database. * * @param array $data * * @return array */ public function parseReadData($data) { $results = []; foreach ($data as $row) { if (is_array($row)) { $key = $row['key']; $value = $row['value']; } elseif (is_object($row)) { $key = $row->key; $value = $row->value; } else { $msg = 'Expected array or object, got ' . gettype($row); throw new \UnexpectedValueException($msg); } Arr::set($results, $key, $value); } return $results; }