CacheDriverTrait.php: add CacheDriverTrait to share code

This commit is contained in:
Zankaria 2025-05-29 23:53:29 +02:00
parent 126314846c
commit 84a22a788e

View file

@ -0,0 +1,20 @@
<?php
namespace Vichan\Data\Driver;
trait CacheDriverTrait {
/**
* Tries to interpret the uri as a path to a unix socket.
*
* @param string $uri
* @return ?string The path to the socket, null if it cannot be interpreted as such.
*/
private static function asUnixSocketPath(string $uri): ?string {
if (str_starts_with($uri, 'unix:')) {
return \substr($uri, 5);
} elseif (str_starts_with($uri, ':')) {
return \substr($uri, 1);
}
return null;
}
}