Skip to content

Commit

Permalink
Rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pulzarraider committed May 14, 2024
1 parent a3e6c1b commit f043e43
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion Tests/Transport/GpsConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ public static function dataProvider(): array
'DSN: Subscription is not created' => [
'dsn' => 'gps://default?topic[name]=foo&subscription[name]=bar&subscription[createIfNotExist]=false',
'options' => [],
//&topic[createIfNotExist]=true
'expectedConfiguration' => new GpsConfiguration(
'foo',
true,
Expand Down
4 changes: 2 additions & 2 deletions Tests/Transport/GpsTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ public function testSetup()

$this->gpsConfiguration
->expects($this->atLeast(1))
->method('createTopicIfNotExist')
->method('isTopicCreationEnabled')
->willReturn(true);

$this->gpsConfiguration
->expects($this->atLeast(1))
->method('createSubscriptionIfNotExist')
->method('isSubscriptionCreationEnabled')
->willReturn(true);

$topicMock = $this->createMock(Topic::class);
Expand Down
20 changes: 10 additions & 10 deletions Transport/GpsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
final class GpsConfiguration implements GpsConfigurationInterface
{
private string $topicName;
private bool $createTopicIfNotExist;
private bool $topicCreationEnabled;
private string $subscriptionName;
private bool $createSubscriptionIfNotExist;
private bool $subscriptionCreationEnabled;
private array $clientConfig;
private array $topicOptions;
private array $subscriptionOptions;
private array $subscriptionPullOptions;

public function __construct(
string $queueName,
bool $isTopicEnabled,
bool $topicCreationEnabled,
string $subscriptionName,
bool $isSubscriptionEnabled,
bool $subscriptionCreationEnabled,
array $clientConfig,
array $topicOptions,
array $subscriptionOptions,
array $subscriptionPullOptions
) {
$this->topicName = $queueName;
$this->createTopicIfNotExist = $isTopicEnabled;
$this->topicCreationEnabled = $topicCreationEnabled;
$this->subscriptionName = $subscriptionName;
$this->createSubscriptionIfNotExist = $isSubscriptionEnabled;
$this->subscriptionCreationEnabled = $subscriptionCreationEnabled;
$this->clientConfig = $clientConfig;
$this->topicOptions = $topicOptions;
$this->subscriptionOptions = $subscriptionOptions;
Expand All @@ -43,19 +43,19 @@ public function getTopicName(): string
return $this->topicName;
}

public function createTopicIfNotExist(): bool
public function isTopicCreationEnabled(): bool
{
return $this->createTopicIfNotExist;
return $this->topicCreationEnabled;
}

public function getSubscriptionName(): string
{
return $this->subscriptionName;
}

public function createSubscriptionIfNotExist(): bool
public function isSubscriptionCreationEnabled(): bool
{
return $this->createSubscriptionIfNotExist;
return $this->subscriptionCreationEnabled;
}

public function getClientConfig(): array
Expand Down
4 changes: 2 additions & 2 deletions Transport/GpsConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ interface GpsConfigurationInterface
{
public function getTopicName(): string;

public function createTopicIfNotExist(): bool;
public function isTopicCreationEnabled(): bool;

public function getSubscriptionName(): string;

public function createSubscriptionIfNotExist(): bool;
public function isSubscriptionCreationEnabled(): bool;

/**
* @see PubSubClient constructor options
Expand Down
4 changes: 2 additions & 2 deletions Transport/GpsTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function setup(): void
{
$topic = $this->pubSubClient->topic($this->gpsConfiguration->getTopicName());

if ($this->gpsConfiguration->createTopicIfNotExist() && false === $topic->exists()) {
if (true === $this->gpsConfiguration->isTopicCreationEnabled() && false === $topic->exists()) {
$topic = $this->pubSubClient->createTopic(
$this->gpsConfiguration->getTopicName(),
$this->gpsConfiguration->getTopicOptions()
Expand All @@ -100,7 +100,7 @@ public function setup(): void

$subscription = $topic->subscription($this->gpsConfiguration->getSubscriptionName());

if ($this->gpsConfiguration->createSubscriptionIfNotExist() && false === $subscription->exists()) {
if (true === $this->gpsConfiguration->isSubscriptionCreationEnabled() && false === $subscription->exists()) {
$topic->subscribe(
$this->gpsConfiguration->getSubscriptionName(),
$this->gpsConfiguration->getSubscriptionOptions()
Expand Down

0 comments on commit f043e43

Please sign in to comment.