Skip to content

Commit

Permalink
Remove UriTemplate::withTemplate method
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 29, 2020
1 parent c867a9c commit cb28d61
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
24 changes: 0 additions & 24 deletions src/UriTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,30 +257,6 @@ public function getVariableNames(): array
return $this->variableNames;
}

/**
* Returns a new instance with the updated template.
*
* This method MUST retain the state of the current instance, and return
* an instance that contains the modified template value.
*
* @param object|string $template a string or an object with the __toString method
*
* @throws SyntaxError if the new template is invalid
*/
public function withTemplate($template): self
{
$template = $this->filterTemplate($template);
if ($template === $this->template) {
return $this;
}

$clone = clone $this;
$clone->template = $template;
$clone->parseExpressions();

return $clone;
}

/**
* Returns the default values used to expand the template.
*
Expand Down
15 changes: 0 additions & 15 deletions tests/UriTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@ public function testGetDefaultVariables(): void
self::assertSame([], $uriTemplateEmpty->getDefaultVariables());
}

/**
* @covers ::withTemplate
*/
public function testWithTemplate(): void
{
$template = '{foo}{bar}';
$uriTemplate = new UriTemplate($template);
$newTemplate = $uriTemplate->withTemplate('{bar}{baz}');
$altTemplate = $uriTemplate->withTemplate($template);

self::assertSame($altTemplate->getTemplate(), $uriTemplate->getTemplate());
self::assertSame($altTemplate->getDefaultVariables(), $uriTemplate->getDefaultVariables());
self::assertNotSame($newTemplate->getTemplate(), $uriTemplate->getTemplate());
}

/**
* @covers ::filterVariables
* @covers ::withDefaultVariables
Expand Down

0 comments on commit cb28d61

Please sign in to comment.