forked from leftypol/leftypol
CacheDriverTrait.php: add CacheDriverTrait to share code
This commit is contained in:
parent
126314846c
commit
84a22a788e
1 changed files with 20 additions and 0 deletions
20
inc/Data/Driver/CacheDriverTrait.php
Normal file
20
inc/Data/Driver/CacheDriverTrait.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue