fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Serializer / Adapter / IgBinary.php
blobddc56126461973b946f31f29ddc0e226dfa3c960
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Serializer\Adapter;
12 use Zend\Serializer\Exception;
13 use Zend\Stdlib\ErrorHandler;
15 class IgBinary extends AbstractAdapter
17 /**
18 * @var string Serialized null value
20 private static $serializedNull = null;
22 /**
23 * Constructor
25 * @throws Exception\ExtensionNotLoadedException If igbinary extension is not present
27 public function __construct($options = null)
29 if (!extension_loaded('igbinary')) {
30 throw new Exception\ExtensionNotLoadedException(
31 'PHP extension "igbinary" is required for this adapter'
35 if (static::$serializedNull === null) {
36 static::$serializedNull = igbinary_serialize(null);
39 parent::__construct($options);
42 /**
43 * Serialize PHP value to igbinary
45 * @param mixed $value
46 * @return string
47 * @throws Exception\RuntimeException on igbinary error
49 public function serialize($value)
51 ErrorHandler::start();
52 $ret = igbinary_serialize($value);
53 $err = ErrorHandler::stop();
55 if ($ret === false) {
56 throw new Exception\RuntimeException('Serialization failed', 0, $err);
59 return $ret;
62 /**
63 * Deserialize igbinary string to PHP value
65 * @param string $serialized
66 * @return mixed
67 * @throws Exception\RuntimeException on igbinary error
69 public function unserialize($serialized)
71 if ($serialized === static::$serializedNull) {
72 return;
75 ErrorHandler::start();
76 $ret = igbinary_unserialize($serialized);
77 $err = ErrorHandler::stop();
79 if ($ret === null) {
80 throw new Exception\RuntimeException('Unserialization failed', 0, $err);
83 return $ret;