composer package updates
[openemr.git] / vendor / zendframework / zend-cache / src / Psr / SerializationTrait.php
blob5a20748ed4c541d58caa5e1cd5cfd31244f715bf
1 <?php
2 /**
3 * @see https://github.com/zendframework/zend-cache for the canonical source repository
4 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
6 */
8 namespace Zend\Cache\Psr;
10 use Zend\Cache\Storage\StorageInterface;
12 /**
13 * Provides common functionality surrounding value de/serialization as required
14 * by both PSR-6 and PSR-16
16 trait SerializationTrait
18 /**
19 * Determine if the given storage adapter requires serialization.
21 * @param StorageInterface $storage
22 * @return bool
24 private function isSerializationRequired(StorageInterface $storage)
26 $capabilities = $storage->getCapabilities();
27 $requiredTypes = ['string', 'integer', 'double', 'boolean', 'NULL', 'array', 'object'];
28 $types = $capabilities->getSupportedDatatypes();
30 foreach ($requiredTypes as $type) {
31 // 'object' => 'object' is OK
32 // 'integer' => 'string' is not (redis)
33 // 'integer' => 'integer' is not (memcache)
34 if (! (isset($types[$type]) && in_array($types[$type], [true, 'array', 'object'], true))) {
35 return true;
39 return false;