X

Create New Item

File Folder

X

Search Results

File "CacheKey.php"

Full path: /home/orbitecv/orbite-school.orbit.et/vendor/beste/in-memory-cache/src/CacheKey.php
File size: 455 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Edit   Back

<?php

namespace Beste\Cache;

/**
 * @internal
 */
final class CacheKey
{
    private function __construct(private readonly string $value) {}

    public static function fromString(string $value): self
    {
        if (preg_match('/^[a-zA-Z0-9_.-]+$/u', $value) !== 1) {
            throw InvalidArgument::invalidKey();
        }

        return new self($value);
    }

    public function toString(): string
    {
        return $this->value;
    }
}