From 55e5188846d0ad34eb22cb318bad4abff2951afd Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Thu, 9 Jan 2025 20:44:43 +1000 Subject: [PATCH] Add docblock comments where relevant This change adds docblock comments where relevant to the code so that it's as clear as possible without going overboard. --- .../RedirectToNewDomainMiddleware.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Middleware/RedirectToNewDomainMiddleware.php b/src/Middleware/RedirectToNewDomainMiddleware.php index cd41083..e0a628f 100644 --- a/src/Middleware/RedirectToNewDomainMiddleware.php +++ b/src/Middleware/RedirectToNewDomainMiddleware.php @@ -15,7 +15,7 @@ /** * RedirectToNewDomainMiddleware performs a 301 redirect the current request - * from one domain (oldDomain) to another (newDomain) if the current request is + * from one domain ($oldDomain) to another ($newDomain) if the current request is * for the old domain. It is designed to simplify moving sites from one domain * to another, especially in cases where the hosting provider does not provide * this functionality natively. @@ -23,12 +23,27 @@ final readonly class RedirectToNewDomainMiddleware implements MiddlewareInterface { public function __construct( + /** + * This is the host portion of the route that was originally requested, e.g., deploywithdockercompose.com, hollows.org, or rspca.org.au. + */ private string $oldDomain, + + /** + * This is the host portion of the route that the request will be redirected to, e.g., asrc.org.au, wwf.org.au, or blackdoginstitute.org.au. + */ private string $newDomain, + + /** + * If you want to perform basic instrumentation, provide this parameter. + */ private ?LoggerInterface $logger = null - ) { - } + ) {} + /** + * process checks the host portion of the current request. If it matches the + * old domain ($oldDomain) the host is set to the new domain ($newDomain) + * and the user is redirected to the revised URI. + */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $this->logger