Skip to content

Commit

Permalink
fix: return separate instance from forApiv1() and forApiV2() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
reliq committed Apr 27, 2021
1 parent fabbddf commit 1544d8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Concern/HotSwapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public function forApiV1(): Twitter
{
$config = $this->getQuerier()
->getConfiguration();
$instance = clone $this;

return $this->usingConfiguration($config->forApiV1());
return $instance->usingConfiguration($config->forApiV1());
}

/**
Expand All @@ -62,7 +63,8 @@ public function forApiV2(): Twitter
{
$config = $this->getQuerier()
->getConfiguration();
$instance = clone $this;

return $this->usingConfiguration($config->forApiV2());
return $instance->usingConfiguration($config->forApiV2());
}
}
4 changes: 4 additions & 0 deletions src/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ public function usingCredentials(
public function usingConfiguration(Configuration $configuration): self;

/**
* Get an instance of Twitter configured for API v1.
*
* @throws InvalidArgumentException
*/
public function forApiV1(): self;

/**
* Get an instance of Twitter configured for API v2.
*
* @throws InvalidArgumentException
*/
public function forApiV2(): self;
Expand Down

0 comments on commit 1544d8b

Please sign in to comment.