Skip to content

Commit f9a9701

Browse files
committed
[TASK] Use DEEPLMOCKAPISERVER supported content and translation
The `DEEPLMOCKAPISERVER` is only a really rudimentary api implementation and do not simulate "full" api in any way. That means, that not all source/target languages are supported like for production api. Therefore, when mock server is used, the supported content and and translated strings are used for test expectations. [TASK] Donate fine grained method to retrieve api url parts `\WebVision\WvDeepltranslate\Configuration` transports the required configuration settings through the system, which is a good approach. This change donates more fine grained read methods to this class, to access api url parts. This is a preparation for an upcoming change.
1 parent c1c263a commit f9a9701

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Classes/Configuration.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,24 @@ public function getApiKey(): string
5050

5151
public function getApiUrl(): string
5252
{
53-
$parseUrl = parse_url($this->apiUrl);
53+
return $this->getApiHost()
54+
. ($this->getApiPort() ? ':' . $this->getApiPort() : '');
55+
}
56+
57+
public function getApiScheme(): string
58+
{
59+
return parse_url($this->apiUrl)['scheme'] ?? 'https';
60+
}
5461

55-
return $parseUrl['host'] . ($parseUrl['port'] ? sprintf(':%s', $parseUrl['port']) : '') ?? '';
62+
public function getApiHost(): string
63+
{
64+
return parse_url($this->apiUrl)['host'] ?? 'localhost';
65+
}
66+
67+
public function getApiPort(): ?int
68+
{
69+
$port = parse_url($this->apiUrl)['port'] ?? null;
70+
return $port ? (int)$port : null;
5671
}
5772

5873
public function getFormality(): string

0 commit comments

Comments
 (0)