Skip to content

Commit

Permalink
Moved validating the endpoint from the construct to the setEndpoint m…
Browse files Browse the repository at this point in the history
…ethod and changed construct to call this method in stead of setting the attribute directly.
  • Loading branch information
pwellingelastique committed Dec 2, 2020
1 parent d59cb06 commit f5be278
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/iTunes/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ class Validator
*/
public function __construct(string $endpoint = self::ENDPOINT_PRODUCTION)
{
if ($endpoint !== self::ENDPOINT_PRODUCTION && $endpoint !== self::ENDPOINT_SANDBOX) {
throw new \InvalidArgumentException("Invalid endpoint '{$endpoint}'");
}

$this->endpoint = $endpoint;
$this->setEndpoint($endpoint);
}

/**
Expand Down Expand Up @@ -129,14 +125,15 @@ public function getEndpoint(): string
}

/**
* set endpoint.
*
* @param string $endpoint
*
* @return $this
* @throws \InvalidArgumentException
*/
public function setEndpoint(string $endpoint): self
{
if ($endpoint !== self::ENDPOINT_PRODUCTION && $endpoint !== self::ENDPOINT_SANDBOX) {
throw new \InvalidArgumentException("Invalid endpoint '{$endpoint}'");
}
$this->endpoint = $endpoint;

return $this;
Expand Down

0 comments on commit f5be278

Please sign in to comment.