mirror of
https://github.com/shlinkio/shlink.git
synced 2024-10-22 20:25:35 +03:00
Simplified mapping of TagInfo objects
This commit is contained in:
parent
19a9d815eb
commit
e6ee4ceae2
3 changed files with 7 additions and 1 deletions
|
@ -110,7 +110,7 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
|
|||
|
||||
return map(
|
||||
$this->getEntityManager()->createNativeQuery($nativeQb->getSQL(), $rsm)->getResult(),
|
||||
static fn (array $row) => new TagInfo($row['tag'], (int) $row['shortUrlsCount'], (int) $row['visitsCount']),
|
||||
TagInfo::fromRawData(...),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,11 @@ final class TagInfo implements JsonSerializable
|
|||
) {
|
||||
}
|
||||
|
||||
public static function fromRawData(array $data): self
|
||||
{
|
||||
return new self($data['tag'], (int) $data['shortUrlsCount'], (int) $data['visitsCount']);
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -14,6 +14,7 @@ final class TagsParams extends AbstractInfinitePaginableListParams
|
|||
private function __construct(
|
||||
public readonly ?string $searchTerm,
|
||||
public readonly Ordering $orderBy,
|
||||
/** @deprecated */
|
||||
public readonly bool $withStats,
|
||||
?int $page,
|
||||
?int $itemsPerPage,
|
||||
|
|
Loading…
Reference in a new issue