Simplify ApiKey entity by exposing key as a readonly prop

This commit is contained in:
Alejandro Celaya
2024-11-04 14:22:39 +01:00
parent b5010e4d8c
commit 79c5418ac2
9 changed files with 28 additions and 46 deletions

View File

@@ -109,7 +109,7 @@ class GenerateKeyCommand extends Command
));
$io = new SymfonyStyle($input, $output);
$io->success(sprintf('Generated API key: "%s"', $apiKey->toString()));
$io->success(sprintf('Generated API key: "%s"', $apiKey->key));
if (! ApiKey::isAdmin($apiKey)) {
ShlinkTable::default($io)->render(

View File

@@ -54,7 +54,7 @@ class ListKeysCommand extends Command
$messagePattern = $this->determineMessagePattern($apiKey);
// Set columns for this row
$rowData = [sprintf($messagePattern, $apiKey), sprintf($messagePattern, $apiKey->name ?? '-')];
$rowData = [sprintf($messagePattern, $apiKey->key), sprintf($messagePattern, $apiKey->name ?? '-')];
if (! $enabledOnly) {
$rowData[] = sprintf($messagePattern, $this->getEnabledSymbol($apiKey));
}

View File

@@ -244,7 +244,7 @@ class ListShortUrlsCommand extends Command
}
if ($input->getOption('show-api-key')) {
$columnsMap['API Key'] = static fn (array $_, ShortUrl $shortUrl): string =>
$shortUrl->authorApiKey?->__toString() ?? '';
$shortUrl->authorApiKey?->key ?? '';
}
if ($input->getOption('show-api-key-name')) {
$columnsMap['API Key Name'] = static fn (array $_, ShortUrl $shortUrl): string|null =>