KeyNormalizer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 22
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onlyValid() 0 4 1
A noInvalid() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of php-cache\cache-bundle package.
5
 *
6
 * (c) 2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Cache\CacheBundle;
13
14
/**
15
 * A class to normalize cache keys.
16
 *
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
class KeyNormalizer
20
{
21
    /**
22
     * Remove all characters that is not supported by PSR6.
23
     *
24
     * @param $key
25
     */
26 1
    public static function onlyValid($key)
27
    {
28 1
        return preg_replace('|[^A-Za-z0-9_\.]|', '', $key);
29
    }
30
31
    /**
32
     * Remove all characters that are marked as reserved in PSR6.
33
     *
34
     * @param string $key
35
     */
36 1
    public static function noInvalid($key)
37
    {
38 1
        return preg_replace('|[\{\}\(\)/\\\@\:]|', '', $key);
39
    }
40
}
41