mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
41 lines
946 B
PHP
41 lines
946 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Rest\ApiKey\Model;
|
|
|
|
use Cake\Chronos\Chronos;
|
|
|
|
final class ApiKeyMeta
|
|
{
|
|
/**
|
|
* @param RoleDefinition[] $roleDefinitions
|
|
*/
|
|
private function __construct(
|
|
public readonly ?string $name,
|
|
public readonly ?Chronos $expirationDate,
|
|
public readonly array $roleDefinitions,
|
|
) {
|
|
}
|
|
|
|
public static function withName(string $name): self
|
|
{
|
|
return new self($name, null, []);
|
|
}
|
|
|
|
public static function withExpirationDate(Chronos $expirationDate): self
|
|
{
|
|
return new self(null, $expirationDate, []);
|
|
}
|
|
|
|
public static function withNameAndExpirationDate(string $name, Chronos $expirationDate): self
|
|
{
|
|
return new self($name, $expirationDate, []);
|
|
}
|
|
|
|
public static function withRoles(RoleDefinition ...$roleDefinitions): self
|
|
{
|
|
return new self(null, null, $roleDefinitions);
|
|
}
|
|
}
|