Conditions | 6 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
75 | public static function getCacheKey($value): string |
||
76 | { |
||
77 | static $preventGarbageCollectorFromDestroyingObject = []; |
||
78 | |||
79 | if (is_object($value)) { |
||
80 | $preventGarbageCollectorFromDestroyingObject[] = $value; |
||
81 | |||
82 | return spl_object_hash($value); |
||
83 | } |
||
84 | |||
85 | if (is_array($value)) { |
||
86 | $key = '[ARRAY|'; |
||
87 | foreach ($value as $i => $modelInCollection) { |
||
88 | $key .= $i . '>' . self::getCacheKey($modelInCollection) . ':'; |
||
89 | } |
||
90 | |||
91 | return $key . ']'; |
||
92 | } |
||
93 | |||
94 | if (is_bool($value)) { |
||
95 | return '[BOOL|' . $value . ']'; |
||
96 | } |
||
97 | |||
98 | if ($value === null) { |
||
99 | return '[NULL]'; |
||
100 | } |
||
101 | |||
102 | return (string) $value; |
||
103 | } |
||
105 |