Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
flexible-shipping-pro
/
vendor_prefixed
/
wpdesk
/
wp-persistence
/
src
/
Decorator
:
SerializedPersistentContainer.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace FSProVendor\WPDesk\Persistence\Decorator; use FSProVendor\WPDesk\Persistence\ElementNotExistsException; use FSProVendor\WPDesk\Persistence\FallbackFromGetTrait; use FSProVendor\WPDesk\Persistence\PersistentContainer; /** * Store values as serialized. Thanks to this the strict typing can be used. * * @package WPDesk\Persistence\Decorator */ class SerializedPersistentContainer implements \FSProVendor\WPDesk\Persistence\PersistentContainer { use FallbackFromGetTrait; private $container; public function __construct(\FSProVendor\WPDesk\Persistence\PersistentContainer $container) { $this->container = $container; } public function get($id) { if ($this->container->has($id)) { return \unserialize($this->container->get($id)); } throw new \FSProVendor\WPDesk\Persistence\ElementNotExistsException(\sprintf('Element %s not exists!', $id)); } public function set(string $id, $value) { if ($value === null) { $this->delete($id); } else { $this->container->set($id, \serialize($value)); } } public function delete(string $id) { $this->container->delete($id); } public function has($id) : bool { return $this->container->has($id); } }