-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from City-of-Helsinki/UHF-9034
UHF-9034: Proper internal address support
- Loading branch information
Showing
15 changed files
with
663 additions
and
170 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\helfi_api_base\Environment; | ||
|
||
/** | ||
* A value object to store address information. | ||
*/ | ||
final class Address { | ||
|
||
/** | ||
* Constructs a new instance. | ||
* | ||
* @param string $domain | ||
* The domain. | ||
* @param string $protocol | ||
* The protocol. | ||
* @param int $port | ||
* The port. | ||
*/ | ||
public function __construct( | ||
public readonly string $domain, | ||
public readonly string $protocol = 'https', | ||
public readonly int $port = 443, | ||
) { | ||
} | ||
|
||
/** | ||
* Gets the address. | ||
* | ||
* @return string | ||
* The address. | ||
*/ | ||
public function getAddress() : string { | ||
$port = ''; | ||
if (!in_array($this->port, [80, 443])) { | ||
$port = sprintf(':%d', $this->port); | ||
} | ||
return sprintf('%s://%s%s', $this->protocol, $this->domain, $port); | ||
} | ||
|
||
} |
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
Oops, something went wrong.