mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
First steps to create ApiKeyMeta
This commit is contained in:
parent
60a8d6e986
commit
9b55389538
3 changed files with 35 additions and 12 deletions
|
@ -105,21 +105,21 @@ class ListKeysCommandTest extends TestCase
|
|||
];
|
||||
yield 'with names' => [
|
||||
[
|
||||
ApiKey::withKey('abc', null, 'Alice'),
|
||||
ApiKey::withKey('def', null, 'Alice and Bob'),
|
||||
ApiKey::withKey('ghi', null, ''),
|
||||
ApiKey::withKey('jkl', null, null),
|
||||
$apiKey1 = ApiKey::withName('Alice'),
|
||||
$apiKey2 = ApiKey::withName('Alice and Bob'),
|
||||
$apiKey3 = ApiKey::withName(''),
|
||||
$apiKey4 = new ApiKey(),
|
||||
],
|
||||
true,
|
||||
<<<OUTPUT
|
||||
+-----+---------------+-----------------+-------+
|
||||
| Key | Name | Expiration date | Roles |
|
||||
+-----+---------------+-----------------+-------+
|
||||
| abc | Alice | - | Admin |
|
||||
| def | Alice and Bob | - | Admin |
|
||||
| ghi | | - | Admin |
|
||||
| jkl | - | - | Admin |
|
||||
+-----+---------------+-----------------+-------+
|
||||
+--------------------------------------+---------------+-----------------+-------+
|
||||
| Key | Name | Expiration date | Roles |
|
||||
+--------------------------------------+---------------+-----------------+-------+
|
||||
| {$apiKey1} | Alice | - | Admin |
|
||||
| {$apiKey2} | Alice and Bob | - | Admin |
|
||||
| {$apiKey3} | | - | Admin |
|
||||
| {$apiKey4} | - | - | Admin |
|
||||
+--------------------------------------+---------------+-----------------+-------+
|
||||
|
||||
OUTPUT,
|
||||
];
|
||||
|
|
18
module/Rest/src/ApiKey/Model/ApiKeyMeta.php
Normal file
18
module/Rest/src/ApiKey/Model/ApiKeyMeta.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Rest\ApiKey\Model;
|
||||
|
||||
final class ApiKeyMeta
|
||||
{
|
||||
public static function withKey(string $key): self
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function withName(string $key): self
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -55,6 +55,11 @@ class ApiKey extends AbstractEntity
|
|||
return $apiKey;
|
||||
}
|
||||
|
||||
public static function withName(string $name): self
|
||||
{
|
||||
return new self(null, $name);
|
||||
}
|
||||
|
||||
public function getExpirationDate(): ?Chronos
|
||||
{
|
||||
return $this->expirationDate;
|
||||
|
|
Loading…
Add table
Reference in a new issue