File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed
Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ public function __construct(
3838 private readonly string $ encoding = 'UTF-8 ' ,
3939 private readonly string $ version = '1.0 ' ,
4040 private readonly string $ rootTag = 'response ' ,
41- ) {
42- }
41+ ) {}
4342
4443 public function format (mixed $ data , ResponseInterface $ response ): ResponseInterface
4544 {
Original file line number Diff line number Diff line change 77use Psr \Http \Message \StreamInterface ;
88use Yiisoft \DataResponse \Modern \DataFormatter \StringDataFormatter ;
99
10+ use const SEEK_SET ;
11+
1012/**
1113 * A lazy stream that formats data only when it's being read.
1214 *
@@ -24,7 +26,11 @@ final class DataStream implements StreamInterface
2426 public function __construct (
2527 private mixed $ data ,
2628 private DataFormatterInterface $ formatter = new StringDataFormatter (),
27- ) {
29+ ) {}
30+
31+ public function __toString (): string
32+ {
33+ return (string ) $ this ->getFormatted ();
2834 }
2935
3036 /**
@@ -49,11 +55,6 @@ public function changeData(mixed $data): void
4955 $ this ->resetState ();
5056 }
5157
52- public function __toString (): string
53- {
54- return (string ) $ this ->getFormatted ();
55- }
56-
5758 public function close (): void
5859 {
5960 $ this ->getFormatted ()->close ();
Original file line number Diff line number Diff line change 99
1010use function strlen ;
1111
12+ use const SEEK_CUR ;
13+ use const SEEK_END ;
14+ use const SEEK_SET ;
15+
1216/**
1317 * A read-only stream implementation for string content.
1418 *
@@ -22,8 +26,7 @@ final class StringStream implements StreamInterface
2226
2327 public function __construct (
2428 private readonly string $ content ,
25- ) {
26- }
29+ ) {}
2730
2831 public function __toString (): string
2932 {
@@ -130,7 +133,7 @@ public function read(int $length): string
130133 public function getContents (): string
131134 {
132135 return $ this ->read (
133- $ this ->getContentSize () - $ this ->position
136+ $ this ->getContentSize () - $ this ->position ,
134137 );
135138 }
136139
You can’t perform that action at this time.
0 commit comments