File tree Expand file tree Collapse file tree 4 files changed +27
-8
lines changed
Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -598,7 +598,7 @@ Using this methods you can use every Redmine API endpoint. The following example
598598``` php
599599$client->requestPut(
600600 '/projects/1.xml',
601- \Redmine\Serializer\XmlSerializer::createFromArray([
601+ (string) \Redmine\Serializer\XmlSerializer::createFromArray([
602602 'project' => [
603603 'name' => 'renamed project',
604604 'custom_fields' => [
@@ -610,7 +610,7 @@ $client->requestPut(
610610 ],
611611 ],
612612 ]
613- ])->getEncoded()
613+ ])
614614);
615615```
616616
@@ -620,7 +620,7 @@ Or to fetch data with complex query parameters you can use `requestGet()` with t
620620
621621``` php
622622$client->requestGet(
623- \Redmine\Serializer\PathSerializer::create(
623+ (string) \Redmine\Serializer\PathSerializer::create(
624624 '/time_entries.json',
625625 [
626626 'f' => ['spent_on'],
@@ -632,7 +632,7 @@ $client->requestGet(
632632 ],
633633 ],
634634 ],
635- )->getPath()
635+ )
636636);
637637```
638638
Original file line number Diff line number Diff line change 44
55use JsonException ;
66use Redmine \Exception \SerializerException ;
7+ use Stringable ;
78
89/**
910 * JsonSerializer.
1011 */
11- final class JsonSerializer
12+ final class JsonSerializer implements Stringable
1213{
1314 /**
1415 * @throws SerializerException if $data is not valid JSON
@@ -55,6 +56,11 @@ public function getEncoded(): string
5556 return $ this ->encoded ;
5657 }
5758
59+ public function __toString (): string
60+ {
61+ return $ this ->getEncoded ();
62+ }
63+
5864 private function decode (string $ encoded ): void
5965 {
6066 $ this ->encoded = $ encoded ;
Original file line number Diff line number Diff line change 22
33namespace Redmine \Serializer ;
44
5+ use Stringable ;
6+
57/**
6- * PathSerializer.
8+ * PathSerializer to handle query parameters .
79 */
8- final class PathSerializer
10+ final class PathSerializer implements Stringable
911{
1012 public static function create (string $ path , array $ queryParams = []): self
1113 {
@@ -38,4 +40,9 @@ public function getPath(): string
3840
3941 return $ this ->path .$ queryString ;
4042 }
43+
44+ public function __toString (): string
45+ {
46+ return $ this ->getPath ();
47+ }
4148}
Original file line number Diff line number Diff line change 55use JsonException ;
66use Redmine \Exception \SerializerException ;
77use SimpleXMLElement ;
8+ use Stringable ;
89use Throwable ;
910
1011/**
1112 * XmlSerializer.
1213 */
13- final class XmlSerializer
14+ final class XmlSerializer implements Stringable
1415{
1516 /**
1617 * @throws SerializerException if $data is not valid XML
@@ -59,6 +60,11 @@ public function getEncoded(): string
5960 return $ this ->encoded ;
6061 }
6162
63+ public function __toString (): string
64+ {
65+ return $ this ->getEncoded ();
66+ }
67+
6268 private function deserialize (string $ encoded ): void
6369 {
6470 $ this ->encoded = $ encoded ;
You can’t perform that action at this time.
0 commit comments