← All changes
|
includes/sdk/google/google/auth/src/CacheTrait.php
+11
-11
1.2.0
→
1.4.2
View file →
| @@ -14,11 +14,11 @@ | ||
| 14 | 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | 15 | * See the License for the specific language governing permissions and |
| 16 | 16 | * limitations under the License. |
| 17 | 17 | */ |
| 18 | -namespace Dudlewebs\WPMCS\Google\Auth; | |
| 18 | +namespace Dudlewebs\WPMCS\GCP\Google\Auth; | |
| 19 | 19 | |
| 20 | -use Dudlewebs\WPMCS\Psr\Cache\CacheItemPoolInterface; | |
| 20 | +use Dudlewebs\WPMCS\GCP\Psr\Cache\CacheItemPoolInterface; | |
| 21 | 21 | trait CacheTrait |
| 22 | 22 | { |
| 23 | 23 | /** |
| 24 | 24 | * @var int |
| @@ -41,13 +41,13 @@ | ||
| 41 | 41 | * @return mixed |
| 42 | 42 | */ |
| 43 | 43 | private function getCachedValue($k) |
| 44 | 44 | { |
| 45 | - if (is_null($this->cache)) { | |
| 45 | + if (\is_null($this->cache)) { | |
| 46 | 46 | return null; |
| 47 | 47 | } |
| 48 | 48 | $key = $this->getFullCacheKey($k); |
| 49 | - if (is_null($key)) { | |
| 49 | + if (\is_null($key)) { | |
| 50 | 50 | return null; |
| 51 | 51 | } |
| 52 | 52 | $cacheItem = $this->cache->getItem($key); |
| 53 | 53 | if ($cacheItem->isHit()) { |
| @@ -62,13 +62,13 @@ | ||
| 62 | 62 | * @return mixed |
| 63 | 63 | */ |
| 64 | 64 | private function setCachedValue($k, $v) |
| 65 | 65 | { |
| 66 | - if (is_null($this->cache)) { | |
| 66 | + if (\is_null($this->cache)) { | |
| 67 | 67 | return null; |
| 68 | 68 | } |
| 69 | 69 | $key = $this->getFullCacheKey($k); |
| 70 | - if (is_null($key)) { | |
| 70 | + if (\is_null($key)) { | |
| 71 | 71 | return null; |
| 72 | 72 | } |
| 73 | 73 | $cacheItem = $this->cache->getItem($key); |
| 74 | 74 | $cacheItem->set($v); |
| @@ -80,17 +80,17 @@ | ||
| 80 | 80 | * @return null|string |
| 81 | 81 | */ |
| 82 | 82 | private function getFullCacheKey($key) |
| 83 | 83 | { |
| 84 | - if (is_null($key)) { | |
| 84 | + if (\is_null($key)) { | |
| 85 | 85 | return null; |
| 86 | 86 | } |
| 87 | - $key = $this->cacheConfig['prefix'] . $key; | |
| 87 | + $key = ($this->cacheConfig['prefix'] ?? '') . $key; | |
| 88 | 88 | // ensure we do not have illegal characters |
| 89 | - $key = preg_replace('|[^a-zA-Z0-9_\.!]|', '', $key); | |
| 89 | + $key = \preg_replace('|[^a-zA-Z0-9_\\.!]|', '', $key); | |
| 90 | 90 | // Hash keys if they exceed $maxKeyLength (defaults to 64) |
| 91 | - if ($this->maxKeyLength && strlen($key) > $this->maxKeyLength) { | |
| 92 | - $key = substr(hash('sha256', $key), 0, $this->maxKeyLength); | |
| 91 | + if ($this->maxKeyLength && \strlen($key) > $this->maxKeyLength) { | |
| 92 | + $key = \substr(\hash('sha256', $key), 0, $this->maxKeyLength); | |
| 93 | 93 | } |
| 94 | 94 | return $key; |
| 95 | 95 | } |
| 96 | 96 | } |