Passed
Pull Request — master (#20015)
by سیدمحمدصالح
12:40 queued 03:55
created

Cache::addValues()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 2
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link https://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license https://www.yiiframework.com/license/
6
 */
7
8
namespace yii\caching;
9
10
use Yii;
11
use yii\base\Component;
12
use yii\helpers\StringHelper;
13
14
/**
15
 * Cache is the base class for cache classes supporting different cache storage implementations.
16
 *
17
 * A data item can be stored in the cache by calling [[set()]] and be retrieved back
18
 * later (in the same or different request) by [[get()]]. In both operations,
19
 * a key identifying the data item is required. An expiration time and/or a [[Dependency|dependency]]
20
 * can also be specified when calling [[set()]]. If the data item expires or the dependency
21
 * changes at the time of calling [[get()]], the cache will return no data.
22
 *
23
 * A typical usage pattern of cache is like the following:
24
 *
25
 * ```php
26
 * $key = 'demo';
27
 * $data = $cache->get($key);
28
 * if ($data === false) {
29
 *     // ...generate $data here...
30
 *     $cache->set($key, $data, $duration, $dependency);
31
 * }
32
 * ```
33
 *
34
 * Because Cache implements the [[\ArrayAccess]] interface, it can be used like an array. For example,
35
 *
36
 * ```php
37
 * $cache['foo'] = 'some data';
38
 * echo $cache['foo'];
39
 * ```
40
 *
41
 * Derived classes should implement the following methods which do the actual cache storage operations:
42
 *
43
 * - [[getValue()]]: retrieve the value with a key (if any) from cache
44
 * - [[setValue()]]: store the value with a key into cache
45
 * - [[addValue()]]: store the value only if the cache does not have this key before
46
 * - [[deleteValue()]]: delete the value with the specified key from cache
47
 * - [[flushValues()]]: delete all values from cache
48
 *
49
 * For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview).
50
 *
51
 * @author Qiang Xue <[email protected]>
52
 * @since 2.0
53
 */
54
abstract class Cache extends Component implements CacheInterface
55
{
56
    /**
57
     * @var string a string prefixed to every cache key so that it is unique globally in the whole cache storage.
58
     * It is recommended that you set a unique cache key prefix for each application if the same cache
59
     * storage is being used by different applications.
60
     *
61
     * To ensure interoperability, only alphanumeric characters should be used.
62
     */
63
    public $keyPrefix;
64
    /**
65
     * @var array|null|false the functions used to serialize and unserialize cached data. Defaults to null, meaning
66
     * using the default PHP `serialize()` and `unserialize()` functions. If you want to use some more efficient
67
     * serializer (e.g. [igbinary](https://pecl.php.net/package/igbinary)), you may configure this property with
68
     * a two-element array. The first element specifies the serialization function, and the second the deserialization
69
     * function. If this property is set false, data will be directly sent to and retrieved from the underlying
70
     * cache component without any serialization or deserialization. You should not turn off serialization if
71
     * you are using [[Dependency|cache dependency]], because it relies on data serialization. Also, some
72
     * implementations of the cache can not correctly save and retrieve data different from a string type.
73
     */
74
    public $serializer;
75
    /**
76
     * @var int default duration in seconds before a cache entry will expire. Default value is 0, meaning infinity.
77
     * This value is used by [[set()]] if the duration is not explicitly given.
78
     * @since 2.0.11
79
     */
80
    public $defaultDuration = 0;
81
82
    /**
83
     * @var bool whether [igbinary serialization](https://pecl.php.net/package/igbinary) is available or not.
84
     */
85
    private $_igbinaryAvailable = false;
86
87
88
    /**
89
     * {@inheritdoc}
90
     */
91 277
    public function init()
92
    {
93 277
        parent::init();
94 277
        $this->_igbinaryAvailable = \extension_loaded('igbinary');
95 277
    }
96
97
    /**
98
     * Builds a normalized cache key from a given key.
99
     *
100
     * If the given key is a string containing alphanumeric characters only and no more than 32 characters,
101
     * then the key will be returned back prefixed with [[keyPrefix]]. Otherwise, a normalized key
102
     * is generated by serializing the given key, applying MD5 hashing, and prefixing with [[keyPrefix]].
103
     *
104
     * @param mixed $key the key to be normalized
105
     * @return string the generated cache key
106
     */
107 251
    public function buildKey($key)
108
    {
109 251
        if (is_string($key)) {
110 207
            $key = ctype_alnum($key) && StringHelper::byteLength($key) <= 32 ? $key : md5($key);
111
        } else {
112 74
            if ($this->_igbinaryAvailable) {
113
                $serializedKey = igbinary_serialize($key);
114
            } else {
115 74
                $serializedKey = serialize($key);
116
            }
117
118 74
            $key = md5($serializedKey);
119
        }
120
121 251
        return $this->keyPrefix . $key;
122
    }
123
124
    /**
125
     * Retrieves a value from cache with a specified key.
126
     * @param mixed $key a key identifying the cached value. This can be a simple string or
127
     * a complex data structure consisting of factors representing the key.
128
     * @return mixed the value stored in cache, false if the value is not in the cache, expired,
129
     * or the dependency associated with the cached data has changed.
130
     */
131 238
    public function get($key)
132
    {
133 238
        $key = $this->buildKey($key);
134 238
        $value = $this->getValue($key);
135 238
        if ($value === false || $this->serializer === false) {
136 208
            return $value;
137 103
        } elseif ($this->serializer === null) {
138 103
            $value = unserialize((string)$value);
139
        } else {
140
            $value = call_user_func($this->serializer[1], $value);
141
        }
142 103
        if (is_array($value) && !($value[1] instanceof Dependency && $value[1]->isChanged($this))) {
143 102
            return $value[0];
144
        }
145
146 7
        return false;
147
    }
148
149
    /**
150
     * Checks whether a specified key exists in the cache.
151
     * This can be faster than getting the value from the cache if the data is big.
152
     * In case a cache does not support this feature natively, this method will try to simulate it
153
     * but has no performance improvement over getting it.
154
     * Note that this method does not check whether the dependency associated
155
     * with the cached data, if there is any, has changed. So a call to [[get]]
156
     * may return false while exists returns true.
157
     * @param mixed $key a key identifying the cached value. This can be a simple string or
158
     * a complex data structure consisting of factors representing the key.
159
     * @return bool true if a value exists in cache, false if the value is not in the cache or expired.
160
     */
161
    public function exists($key)
162
    {
163
        $key = $this->buildKey($key);
164
        $value = $this->getValue($key);
165
166
        return $value !== false;
167
    }
168
169
    /**
170
     * Retrieves multiple values from cache with the specified keys.
171
     * Some caches (such as memcache, apc) allow retrieving multiple cached values at the same time,
172
     * which may improve the performance. In case a cache does not support this feature natively,
173
     * this method will try to simulate it.
174
     *
175
     * @param string[] $keys list of string keys identifying the cached values
176
     * @return array list of cached values corresponding to the specified keys. The array
177
     * is returned in terms of (key, value) pairs.
178
     * If a value is not cached or expired, the corresponding array value will be false.
179
     * @deprecated This method is an alias for [[multiGet()]] and will be removed in 2.1.0.
180
     */
181
    public function mget($keys)
182
    {
183
        return $this->multiGet($keys);
184
    }
185
186
    /**
187
     * Retrieves multiple values from cache with the specified keys.
188
     * Some caches (such as memcache, apc) allow retrieving multiple cached values at the same time,
189
     * which may improve the performance. In case a cache does not support this feature natively,
190
     * this method will try to simulate it.
191
     * @param string[] $keys list of string keys identifying the cached values
192
     * @return array list of cached values corresponding to the specified keys. The array
193
     * is returned in terms of (key, value) pairs.
194
     * If a value is not cached or expired, the corresponding array value will be false.
195
     * @since 2.0.7
196
     */
197 34
    public function multiGet($keys)
198
    {
199 34
        $keyMap = [];
200 34
        foreach ($keys as $key) {
201 34
            $keyMap[$key] = $this->buildKey($key);
202
        }
203 34
        $values = $this->getValues(array_values($keyMap));
204 34
        $results = [];
205 34
        foreach ($keyMap as $key => $newKey) {
206 34
            $results[$key] = false;
207 34
            if (isset($values[$newKey])) {
208 34
                if ($this->serializer === false) {
209
                    $results[$key] = $values[$newKey];
210
                } else {
211 34
                    $value = $this->serializer === null ? unserialize($values[$newKey])
212 34
                        : call_user_func($this->serializer[1], $values[$newKey]);
213
214 34
                    if (is_array($value) && !($value[1] instanceof Dependency && $value[1]->isChanged($this))) {
215 34
                        $results[$key] = $value[0];
216
                    }
217
                }
218
            }
219
        }
220
221 34
        return $results;
222
    }
223
224
    /**
225
     * Stores a value identified by a key into cache.
226
     * If the cache already contains such a key, the existing value and
227
     * expiration time will be replaced with the new ones, respectively.
228
     *
229
     * @param mixed $key a key identifying the value to be cached. This can be a simple string or
230
     * a complex data structure consisting of factors representing the key.
231
     * @param mixed $value the value to be cached
232
     * @param int|null $duration default duration in seconds before the cache will expire. If not set,
233
     * default [[defaultDuration]] value is used.
234
     * @param Dependency|null $dependency dependency of the cached item. If the dependency changes,
235
     * the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
236
     * This parameter is ignored if [[serializer]] is false.
237
     * @return bool whether the value is successfully stored into cache
238
     */
239 151
    public function set($key, $value, $duration = null, $dependency = null)
240
    {
241 151
        if ($duration === null) {
242 84
            $duration = $this->defaultDuration;
243
        }
244
245 151
        if ($dependency !== null && $this->serializer !== false) {
246 31
            $dependency->evaluateDependency($this);
247
        }
248 151
        if ($this->serializer === null) {
249 151
            $value = serialize([$value, $dependency]);
250
        } elseif ($this->serializer !== false) {
251
            $value = call_user_func($this->serializer[0], [$value, $dependency]);
252
        }
253 151
        $key = $this->buildKey($key);
254
255 151
        return $this->setValue($key, $value, $duration);
256
    }
257
258
    /**
259
     * Stores multiple items in cache. Each item contains a value identified by a key.
260
     * If the cache already contains such a key, the existing value and
261
     * expiration time will be replaced with the new ones, respectively.
262
     *
263
     * @param array $items the items to be cached, as key-value pairs.
264
     * @param int|null $duration default duration in seconds before the cache will expire. If not set,
265
     * default [[defaultDuration]] value is used.
266
     * @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
267
     * the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
268
     * This parameter is ignored if [[serializer]] is false.
269
     * @return array array of failed keys
270
     * @deprecated This method is an alias for [[multiSet()]] and will be removed in 2.1.0.
271
     */
272
    public function mset($items, $duration = null, $dependency = null)
273
    {
274
        return $this->multiSet($items, $duration, $dependency);
275
    }
276
277
    /**
278
     * Stores multiple items in cache. Each item contains a value identified by a key.
279
     * If the cache already contains such a key, the existing value and
280
     * expiration time will be replaced with the new ones, respectively.
281
     *
282
     * @param array $items the items to be cached, as key-value pairs.
283
     * @param int|null $duration default duration in seconds before the cache will expire. If not set,
284
     * default [[defaultDuration]] value is used.
285
     * @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
286
     * the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
287
     * This parameter is ignored if [[serializer]] is false.
288
     * @return array array of failed keys
289
     * @since 2.0.7
290
     */
291 35
    public function multiSet($items, $duration = null, $dependency = null)
292
    {
293 35
        if ($duration === null) {
294 27
            $duration = $this->defaultDuration;
295
        }
296
297 35
        $data = $this->prepareCacheData($items, $dependency);
298
299 35
        return $this->setValues($data, $duration);
300
    }
301
302
    /**
303
     * Stores multiple items in cache. Each item contains a value identified by a key.
304
     * If the cache already contains such a key, the existing value and expiration time will be preserved.
305
     *
306
     * @param array $items the items to be cached, as key-value pairs.
307
     * @param int $duration default number of seconds in which the cached values will expire. 0 means never expire.
308
     * @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
309
     * the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
310
     * This parameter is ignored if [[serializer]] is false.
311
     * @return array array of failed keys
312
     * @deprecated This method is an alias for [[multiAdd()]] and will be removed in 2.1.0.
313
     */
314
    public function madd($items, $duration = 0, $dependency = null)
315
    {
316
        return $this->multiAdd($items, $duration, $dependency);
317
    }
318
319
    /**
320
     * Stores multiple items in cache. Each item contains a value identified by a key.
321
     * If the cache already contains such a key, the existing value and expiration time will be preserved.
322
     *
323
     * @param array $items the items to be cached, as key-value pairs.
324
     * @param int $duration default number of seconds in which the cached values will expire. 0 means never expire.
325
     * @param Dependency|null $dependency dependency of the cached items. If the dependency changes,
326
     * the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
327
     * This parameter is ignored if [[serializer]] is false.
328
     * @return array array of failed keys
329
     * @since 2.0.7
330
     */
331 4
    public function multiAdd($items, $duration = 0, $dependency = null)
332
    {
333 4
        $data = $this->prepareCacheData($items, $dependency);
334
335 4
        return $this->addValues($data, $duration);
336
    }
337
338
    /**
339
     * Prepares data for caching by serializing values and evaluating dependencies.
340
     *
341
     * @param array $items The items to be cached.
342
     * @param mixed $dependency The dependency to be evaluated.
343
     *
344
     * @return array The prepared data for caching.
345
     */
346 39
    private function prepareCacheData($items, $dependency)
347
    {
348 39
        if ($dependency !== null && $this->serializer !== false) {
349
            $dependency->evaluateDependency($this);
350
        }
351
352 39
        $data = [];
353 39
        foreach ($items as $key => $value) {
354 39
            if ($this->serializer === null) {
355 39
                $value = serialize([$value, $dependency]);
356
            } elseif ($this->serializer !== false) {
357
                $value = call_user_func($this->serializer[0], [$value, $dependency]);
358
            }
359
360 39
            $key = $this->buildKey($key);
361 39
            $data[$key] = $value;
362
        }
363
364 39
        return $data;
365
    }
366
367
    /**
368
     * Stores a value identified by a key into cache if the cache does not contain this key.
369
     * Nothing will be done if the cache already contains the key.
370
     * @param mixed $key a key identifying the value to be cached. This can be a simple string or
371
     * a complex data structure consisting of factors representing the key.
372
     * @param mixed $value the value to be cached
373
     * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
374
     * @param Dependency|null $dependency dependency of the cached item. If the dependency changes,
375
     * the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
376
     * This parameter is ignored if [[serializer]] is false.
377
     * @return bool whether the value is successfully stored into cache
378
     */
379 8
    public function add($key, $value, $duration = 0, $dependency = null)
380
    {
381 8
        if ($dependency !== null && $this->serializer !== false) {
382
            $dependency->evaluateDependency($this);
383
        }
384 8
        if ($this->serializer === null) {
385 8
            $value = serialize([$value, $dependency]);
386
        } elseif ($this->serializer !== false) {
387
            $value = call_user_func($this->serializer[0], [$value, $dependency]);
388
        }
389 8
        $key = $this->buildKey($key);
390
391 8
        return $this->addValue($key, $value, $duration);
392
    }
393
394
    /**
395
     * Deletes a value with the specified key from cache.
396
     * @param mixed $key a key identifying the value to be deleted from cache. This can be a simple string or
397
     * a complex data structure consisting of factors representing the key.
398
     * @return bool if no error happens during deletion
399
     */
400 133
    public function delete($key)
401
    {
402 133
        $key = $this->buildKey($key);
403
404 133
        return $this->deleteValue($key);
405
    }
406
407
    /**
408
     * Deletes all values from cache.
409
     * Be careful of performing this operation if the cache is shared among multiple applications.
410
     * @return bool whether the flush operation was successful.
411
     */
412 48
    public function flush()
413
    {
414 48
        return $this->flushValues();
415
    }
416
417
    /**
418
     * Retrieves a value from cache with a specified key.
419
     * This method should be implemented by child classes to retrieve the data
420
     * from specific cache storage.
421
     * @param string $key a unique key identifying the cached value
422
     * @return mixed|false the value stored in cache, false if the value is not in the cache or expired. Most often
423
     * value is a string. If you have disabled [[serializer]], it could be something else.
424
     */
425
    abstract protected function getValue($key);
426
427
    /**
428
     * Stores a value identified by a key in cache.
429
     * This method should be implemented by child classes to store the data
430
     * in specific cache storage.
431
     * @param string $key the key identifying the value to be cached
432
     * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]],
433
     * it could be something else.
434
     * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
435
     * @return bool true if the value is successfully stored into cache, false otherwise
436
     */
437
    abstract protected function setValue($key, $value, $duration);
438
439
    /**
440
     * Stores a value identified by a key into cache if the cache does not contain this key.
441
     * This method should be implemented by child classes to store the data
442
     * in specific cache storage.
443
     * @param string $key the key identifying the value to be cached
444
     * @param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]],
445
     * it could be something else.
446
     * @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
447
     * @return bool true if the value is successfully stored into cache, false otherwise
448
     */
449
    abstract protected function addValue($key, $value, $duration);
450
451
    /**
452
     * Deletes a value with the specified key from cache
453
     * This method should be implemented by child classes to delete the data from actual cache storage.
454
     * @param string $key the key of the value to be deleted
455
     * @return bool if no error happens during deletion
456
     */
457
    abstract protected function deleteValue($key);
458
459
    /**
460
     * Deletes all values from cache.
461
     * Child classes may implement this method to realize the flush operation.
462
     * @return bool whether the flush operation was successful.
463
     */
464
    abstract protected function flushValues();
465
466
    /**
467
     * Retrieves multiple values from cache with the specified keys.
468
     * The default implementation calls [[getValue()]] multiple times to retrieve
469
     * the cached values one by one. If the underlying cache storage supports multiget,
470
     * this method should be overridden to exploit that feature.
471
     * @param array $keys a list of keys identifying the cached values
472
     * @return array a list of cached values indexed by the keys
473
     */
474 30
    protected function getValues($keys)
475
    {
476 30
        $results = [];
477 30
        foreach ($keys as $key) {
478 30
            $results[$key] = $this->getValue($key);
479
        }
480
481 30
        return $results;
482
    }
483
484
    /**
485
     * Stores multiple key-value pairs in cache.
486
     * The default implementation calls [[setValue()]] multiple times store values one by one. If the underlying cache
487
     * storage supports multi-set, this method should be overridden to exploit that feature.
488
     * @param array $data array where key corresponds to cache key while value is the value stored
489
     * @param int $duration the number of seconds in which the cached values will expire. 0 means never expire.
490
     * @return array array of failed keys
491
     */
492 35
    protected function setValues($data, $duration)
493
    {
494 35
        $failedKeys = [];
495 35
        foreach ($data as $key => $value) {
496 35
            if ($this->setValue($key, $value, $duration) === false) {
497
                $failedKeys[] = $key;
498
            }
499
        }
500
501 35
        return $failedKeys;
502
    }
503
504
    /**
505
     * Adds multiple key-value pairs to cache.
506
     * The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache
507
     * storage supports multi-add, this method should be overridden to exploit that feature.
508
     * @param array $data array where key corresponds to cache key while value is the value stored.
509
     * @param int $duration the number of seconds in which the cached values will expire. 0 means never expire.
510
     * @return array array of failed keys
511
     */
512 4
    protected function addValues($data, $duration)
513
    {
514 4
        $failedKeys = [];
515 4
        foreach ($data as $key => $value) {
516 4
            if ($this->addValue($key, $value, $duration) === false) {
517 4
                $failedKeys[] = $key;
518
            }
519
        }
520
521 4
        return $failedKeys;
522
    }
523
524
    /**
525
     * Returns whether there is a cache entry with a specified key.
526
     * This method is required by the interface [[\ArrayAccess]].
527
     * @param string $key a key identifying the cached value
528
     * @return bool
529
     */
530
    #[\ReturnTypeWillChange]
531
    public function offsetExists($key)
532
    {
533
        return $this->get($key) !== false;
534
    }
535
536
    /**
537
     * Retrieves the value from cache with a specified key.
538
     * This method is required by the interface [[\ArrayAccess]].
539
     * @param string $key a key identifying the cached value
540
     * @return mixed the value stored in cache, false if the value is not in the cache or expired.
541
     */
542
    #[\ReturnTypeWillChange]
543 4
    public function offsetGet($key)
544
    {
545 4
        return $this->get($key);
546
    }
547
548
    /**
549
     * Stores the value identified by a key into cache.
550
     * If the cache already contains such a key, the existing value will be
551
     * replaced with the new ones. To add expiration and dependencies, use the [[set()]] method.
552
     * This method is required by the interface [[\ArrayAccess]].
553
     * @param string $key the key identifying the value to be cached
554
     * @param mixed $value the value to be cached
555
     */
556
    #[\ReturnTypeWillChange]
557 40
    public function offsetSet($key, $value)
558
    {
559 40
        $this->set($key, $value);
560 40
    }
561
562
    /**
563
     * Deletes the value with the specified key from cache
564
     * This method is required by the interface [[\ArrayAccess]].
565
     * @param string $key the key of the value to be deleted
566
     */
567
    #[\ReturnTypeWillChange]
568
    public function offsetUnset($key)
569
    {
570
        $this->delete($key);
571
    }
572
573
    /**
574
     * Method combines both [[set()]] and [[get()]] methods to retrieve value identified by a $key,
575
     * or to store the result of $callable execution if there is no cache available for the $key.
576
     *
577
     * Usage example:
578
     *
579
     * ```php
580
     * public function getTopProducts($count = 10) {
581
     *     $cache = $this->cache; // Could be Yii::$app->cache
582
     *     return $cache->getOrSet(['top-n-products', 'n' => $count], function () use ($count) {
583
     *         return Products::find()->mostPopular()->limit($count)->all();
584
     *     }, 1000);
585
     * }
586
     * ```
587
     *
588
     * @param mixed $key a key identifying the value to be cached. This can be a simple string or
589
     * a complex data structure consisting of factors representing the key.
590
     * @param callable|\Closure $callable the callable or closure that will be used to generate a value to be cached.
591
     * If you use $callable that can return `false`, then keep in mind that [[getOrSet()]] may work inefficiently
592
     * because the [[yii\caching\Cache::get()]] method uses `false` return value to indicate the data item is not found
593
     * in the cache. Thus, caching of `false` value will lead to unnecessary internal calls.
594
     * @param int|null $duration default duration in seconds before the cache will expire. If not set,
595
     * [[defaultDuration]] value will be used.
596
     * @param Dependency|null $dependency dependency of the cached item. If the dependency changes,
597
     * the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
598
     * This parameter is ignored if [[serializer]] is `false`.
599
     * @return mixed result of $callable execution
600
     * @since 2.0.11
601
     */
602 8
    public function getOrSet($key, $callable, $duration = null, $dependency = null)
603
    {
604 8
        if (($value = $this->get($key)) !== false) {
605 4
            return $value;
606
        }
607
608 8
        $value = call_user_func($callable, $this);
609 8
        if (!$this->set($key, $value, $duration, $dependency)) {
610
            Yii::warning('Failed to set cache value for key ' . json_encode($key), __METHOD__);
611
        }
612
613 8
        return $value;
614
    }
615
}
616