Passed
Push — main ( 7054df...cd5745 )
by Sílvio
07:40 queued 04:49
created

CacheRedisHelper::mergeRecursive()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 19
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 6
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 19
rs 9.6111
1
<?php
2
3
namespace Silviooosilva\CacheerPhp\Helpers;
4
5
use Silviooosilva\CacheerPhp\Helpers\CacheerHelper;
6
use Silviooosilva\CacheerPhp\Exceptions\CacheRedisException;
7
8
/**
9
 * Class CacheRedisHelper
10
 * @author Sílvio Silva <https://github.com/silviooosilva>
11
 * @package Silviooosilva\CacheerPhp
12
 */
13
class CacheRedisHelper
14
{
15
16
  /**
17
  * @param mixed $data
18
  * @param bool  $serialize
19
  * @return mixed
20
  */
21
  public static function serialize(mixed $data, bool $serialize = true)
22
  {
23
    if($serialize) {
24
      return serialize($data);
25
    }
26
27
    return unserialize($data);
28
29
  }
30
31
    /**
32
     * @param array $item
33
     * @return void
34
     */
35
    public static function validateCacheItem(array $item)
36
    {
37
        CacheerHelper::validateCacheItem(
38
            $item,
39
            fn($msg) => CacheRedisException::create($msg)
40
        );
41
    }
42
43
    /**
44
     * @param array $options
45
     * @return array
46
     */
47
    public static function mergeCacheData($cacheData)
48
    {
49
        return CacheerHelper::mergeCacheData($cacheData);
50
    }
51
52
  /**
53
    * @param mixed $currentCacheData
54
    * @param mixed $cacheData
55
    * @return array
56
    */
57
  public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
58
  {
59
      return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
60
  }
61
62
}
63
64