-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include visited short URL information with every visit
- Loading branch information
Showing
10 changed files
with
106 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
module/Core/src/Visit/Transformer/VisitDataTransformer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Core\Visit\Transformer; | ||
|
||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl; | ||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface; | ||
use Shlinkio\Shlink\Core\Visit\Entity\Visit; | ||
|
||
readonly class VisitDataTransformer implements VisitDataTransformerInterface | ||
{ | ||
public function __construct(private ShortUrlStringifierInterface $stringifier) | ||
{ | ||
} | ||
|
||
public function transform(Visit $visit): array | ||
{ | ||
return $visit->toArray(fn (ShortUrl $shortUrl) => [ | ||
Check failure on line 19 in module/Core/src/Visit/Transformer/VisitDataTransformer.php GitHub Actions / static-analysis (8.3, stan)
|
||
'shortCode' => $shortUrl->getShortCode(), | ||
'domain' => $shortUrl->getDomain()?->authority, | ||
'shortUrl' => $this->stringifier->stringify($shortUrl), | ||
]); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
module/Core/src/Visit/Transformer/VisitDataTransformerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Core\Visit\Transformer; | ||
|
||
use Shlinkio\Shlink\Core\Visit\Entity\Visit; | ||
|
||
interface VisitDataTransformerInterface | ||
{ | ||
public function transform(Visit $visit): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters