Skip to content

Commit 32224d4

Browse files
committed
Improve Modifier test suite
1 parent b1794c4 commit 32224d4

File tree

3 files changed

+110
-111
lines changed

3 files changed

+110
-111
lines changed

components/Modifier.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ public function toString(): string
103103

104104
public function toDisplayString(): string
105105
{
106-
$uri = $this->uri instanceof Uri ? $this->uri : Uri::new($this->uri);
107-
108-
return $uri->toDisplayString();
106+
return ($this->uri instanceof Uri ? $this->uri : Uri::new($this->toString()))->toDisplayString();
109107
}
110108

111109
public function withScheme(Stringable|string|null $scheme): static
@@ -1040,32 +1038,32 @@ public function getIdnUriString(): string
10401038
* Fragment modifier methods
10411039
*********************************/
10421040

1043-
public function appendDirectives(FragmentDirectives|Directive|Stringable|string ...$directives): static
1041+
public function appendFragmentDirectives(FragmentDirectives|Directive|Stringable|string ...$directives): static
10441042
{
10451043
return $this->withFragment(FragmentDirectives::fromUri($this->uri())->append(...$directives));
10461044
}
10471045

1048-
public function prependDirectives(FragmentDirectives|Directive|Stringable|string ...$directives): static
1046+
public function prependFragmentDirectives(FragmentDirectives|Directive|Stringable|string ...$directives): static
10491047
{
10501048
return $this->withFragment(FragmentDirectives::fromUri($this->uri())->prepend(...$directives));
10511049
}
10521050

1053-
public function removeDirectives(int ...$offset): static
1051+
public function removeFragmentDirectives(int ...$offset): static
10541052
{
10551053
return $this->withFragment(FragmentDirectives::fromUri($this->uri())->remove(...$offset));
10561054
}
10571055

1058-
public function replaceDirective(int $offset, Directive|Stringable|string $directive): static
1056+
public function replaceFragmentDirective(int $offset, Directive|Stringable|string $directive): static
10591057
{
10601058
return $this->withFragment(FragmentDirectives::fromUri($this->uri())->replace($offset, $directive));
10611059
}
10621060

1063-
public function sliceDirectives(int $offset, ?int $length): static
1061+
public function sliceFragmentDirectives(int $offset, ?int $length): static
10641062
{
10651063
return $this->withFragment(FragmentDirectives::fromUri($this->uri())->slice($offset, $length));
10661064
}
10671065

1068-
public function filterDirectives(callable $callback): static
1066+
public function filterFragmentDirectives(callable $callback): static
10691067
{
10701068
return $this->withFragment(FragmentDirectives::fromUri($this->uri())->filter($callback));
10711069
}

components/ModifierTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ public function test_it_can_append_the_fragment(
10061006
): void {
10071007
self::assertSame(
10081008
$expectedFragment,
1009-
Modifier::from($uri)->appendDirectives($directive)->uri()->getFragment()
1009+
Modifier::from($uri)->appendFragmentDirectives($directive)->uri()->getFragment()
10101010
);
10111011
}
10121012

@@ -1039,7 +1039,7 @@ public function test_it_can_prepend_the_fragment(
10391039
): void {
10401040
self::assertSame(
10411041
$expectedFragment,
1042-
Modifier::from($uri)->prependDirectives($directive)->uri()->getFragment()
1042+
Modifier::from($uri)->prependFragmentDirectives($directive)->uri()->getFragment()
10431043
);
10441044
}
10451045

0 commit comments

Comments
 (0)