key = $key; } protected abstract function toObject($value); protected abstract function toValue($object); protected abstract function defaultObject(); public function get() { if($this->cache === NULL) { $value = get_option($this->key, NULL); if($value === NULL) { $this->cache = $this->defaultObject(); } else { $object = $this->toObject($value); if($object === NULL) { $this->cache = $this->defaultObject(); } else { $this->cache = $object; } } } return $this->cache; } public function set($object) { update_option($this->key, $this->toValue($object)); $this->cache = $object; } public function setDefaults() { $this->set($this->defaultObject()); } }