Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12741421
WithPrefix.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
WithPrefix.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\Cache\Features
;
use
InvalidArgumentException
;
trait
WithPrefix
{
///
/// Properties
///
private
string
$prefix
=
""
;
///
/// Getters and setters
///
public
function
getPrefix
()
:
string
{
if
(
$this
->
prefix
===
""
)
{
throw
new
InvalidArgumentException
(
"This cache doesn't use prefix"
);
}
return
$this
->
prefix
;
}
protected
function
getUnsafePrefix
()
:
string
{
return
$this
->
prefix
;
}
public
function
hasPrefix
()
:
bool
{
return
$this
->
prefix
!==
""
;
}
/**
* Allows to share ab instance with several applications
* by prefixing the keys.
*
* @throws InvalidArgumentException
*/
public
function
setPrefix
(
string
$prefix
)
:
self
{
if
(
$prefix
===
""
)
{
throw
new
InvalidArgumentException
(
"Prefix must be a non-empty string"
);
}
$this
->
prefix
=
$prefix
;
return
$this
;
}
public
function
clearPrefix
()
:
self
{
$this
->
prefix
=
""
;
return
$this
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 16, 13:26 (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3160480
Default Alt Text
WithPrefix.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment