-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrefixedUtilityTrait.php
47 lines (42 loc) · 1.01 KB
/
PrefixedUtilityTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
* This file is part of php-cache organization.
*
* (c) 2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Cache\Prefixed;
/**
* Utility to reduce code suplication between the Prefixed* decoratrs.
*
* @author ndobromirov
*/
trait PrefixedUtilityTrait
{
/**
* @type string Prefix to use for key namespaceing.
*/
private $prefix;
/**
* Add namespace prefix on the key.
*
* @param array $keys Reference to the key. It is mutated.
*/
private function prefixValue(&$key)
{
$key = $this->prefix.$key;
}
/**
* Adds a namespace prefix on a list of keys.
*
* @param array $keys Reference to the list of keys. The list is mutated.
*/
private function prefixValues(array &$keys)
{
foreach ($keys as &$key) {
$this->prefixValue($key);
}
}
}