Skip to content

Commit be66f06

Browse files
committed
Remove getter of baseUrl and secret
1 parent 24ea7f5 commit be66f06

2 files changed

Lines changed: 15 additions & 31 deletions

File tree

src/Util/UrlBuilder.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class UrlBuilder
4343

4444
private string $secret;
4545

46-
private string $serverBaseUrl;
46+
private string $baseUrl;
4747

48-
public function __construct(string $secret, string $serverBaseUrl, string $hashingAlgorithm)
48+
public function __construct(string $secret, string $baseUrl, string $hashingAlgorithm)
4949
{
5050
$this->setSecret($secret);
51-
$this->setServerBaseUrl($serverBaseUrl);
51+
$this->setBaseUrl($baseUrl);
5252
$this->setHashingAlgorithm($hashingAlgorithm);
5353
}
5454

@@ -60,28 +60,18 @@ public function setSecret(string $secret): self
6060
return $this;
6161
}
6262

63-
public function getSecret(): string
64-
{
65-
return $this->secret;
66-
}
67-
68-
public function setServerBaseUrl(string $serverBaseUrl): self
63+
public function setBaseUrl(string $baseUrl): self
6964
{
7065
// add tailing dir-separator if missing
71-
if ('/' != mb_substr($serverBaseUrl, -1)) {
72-
$serverBaseUrl .= '/';
66+
if ('/' != mb_substr($baseUrl, -1)) {
67+
$baseUrl .= '/';
7368
}
7469

75-
$this->serverBaseUrl = $serverBaseUrl;
70+
$this->baseUrl = $baseUrl;
7671

7772
return $this;
7873
}
7974

80-
public function getServerBaseUrl(): string
81-
{
82-
return $this->serverBaseUrl;
83-
}
84-
8575
public function setHashingAlgorithm(string $hashingAlgorithm): self
8676
{
8777
$this->hashingAlgorithm = $hashingAlgorithm;
@@ -100,7 +90,7 @@ public function getHashingAlgorithm(): string
10090
*/
10191
public function buildUrl(string $method = '', string $params = '', bool $append = true): string
10292
{
103-
return $this->serverBaseUrl . 'api/' . $method . ($append ? '?' . $this->buildQs($method, $params) : '');
93+
return $this->baseUrl . 'api/' . $method . ($append ? '?' . $this->buildQs($method, $params) : '');
10494
}
10595

10696
/**

tests/Util/UrlBuilderTest.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,24 @@ public function testSecret(): void
4949
// arrange
5050
$newSecret = $this->faker->password(128);
5151

52-
// initial value
53-
$this->assertEquals('any secret', $this->urlBuilder->getSecret());
54-
5552
// set new value
56-
$this->urlBuilder->setSecret($newSecret);
57-
$this->assertEquals($newSecret, $this->urlBuilder->getSecret());
53+
$urlBuilder = $this->urlBuilder->setSecret($newSecret);
54+
$this->assertInstanceOf(UrlBuilder::class, $urlBuilder);
5855
}
5956

60-
public function testServerBaseUrl(): void
57+
public function testBaseUrl(): void
6158
{
6259
// arrange
6360
$urlWithoutTailingSeparator = $this->faker->url;
6461
$urlWithTailingSeparator = $urlWithoutTailingSeparator . '/';
6562

66-
// initial value
67-
$this->assertEquals('any url/', $this->urlBuilder->getServerBaseUrl());
68-
6963
// set value 1 (without)
70-
$this->urlBuilder->setServerBaseUrl($urlWithoutTailingSeparator);
71-
$this->assertEquals($urlWithTailingSeparator, $this->urlBuilder->getServerBaseUrl());
64+
$urlBuilder = $this->urlBuilder->setBaseUrl($urlWithoutTailingSeparator);
65+
$this->assertInstanceOf(UrlBuilder::class, $urlBuilder);
7266

7367
// set value 2 (with)
74-
$this->urlBuilder->setServerBaseUrl($urlWithTailingSeparator);
75-
$this->assertEquals($urlWithTailingSeparator, $this->urlBuilder->getServerBaseUrl());
68+
$urlBuilder = $this->urlBuilder->setBaseUrl($urlWithTailingSeparator);
69+
$this->assertInstanceOf(UrlBuilder::class, $urlBuilder);
7670
}
7771

7872
public function testHashingAlgorithm(): void

0 commit comments

Comments
 (0)