Skip to content

Commit 767a42c

Browse files
[12.x] Added JsonSerializable interface to Uri Class (#56097)
* Added JsonSerializable interface to Uri class and implemented jsonSerialize function * Updated return type of jsonSerialize function in Uri.php * Update Uri.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent a44bfd8 commit 767a42c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Illuminate/Support/Uri.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
use Illuminate\Support\Traits\Dumpable;
1212
use Illuminate\Support\Traits\Macroable;
1313
use Illuminate\Support\Traits\Tappable;
14+
use JsonSerializable;
1415
use League\Uri\Contracts\UriInterface;
1516
use League\Uri\Uri as LeagueUri;
1617
use SensitiveParameter;
1718
use Stringable;
1819

19-
class Uri implements Htmlable, Responsable, Stringable
20+
class Uri implements Htmlable, JsonSerializable, Responsable, Stringable
2021
{
2122
use Conditionable, Dumpable, Macroable, Tappable;
2223

@@ -409,6 +410,16 @@ public function getUri(): UriInterface
409410
return $this->uri;
410411
}
411412

413+
/**
414+
* Convert the object into a value that is JSON serializable.
415+
*
416+
* @return string
417+
*/
418+
public function jsonSerialize(): string
419+
{
420+
return $this->value();
421+
}
422+
412423
/**
413424
* Get the string representation of the URI.
414425
*/

0 commit comments

Comments
 (0)