First steps to create ApiKeyMeta

This commit is contained in:
Alejandro Celaya 2021-03-14 08:28:21 +01:00 committed by Alejandro Celaya
parent 60a8d6e986
commit 9b55389538
3 changed files with 35 additions and 12 deletions

View file

@ -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,
];

View 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
{
}
}

View file

@ -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;