File tree 4 files changed +27
-8
lines changed
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
598
598
``` php
599
599
$client->requestPut(
600
600
'/projects/1.xml',
601
- \Redmine\Serializer\XmlSerializer::createFromArray([
601
+ (string) \Redmine\Serializer\XmlSerializer::createFromArray([
602
602
'project' => [
603
603
'name' => 'renamed project',
604
604
'custom_fields' => [
@@ -610,7 +610,7 @@ $client->requestPut(
610
610
],
611
611
],
612
612
]
613
- ])->getEncoded()
613
+ ])
614
614
);
615
615
```
616
616
@@ -620,7 +620,7 @@ Or to fetch data with complex query parameters you can use `requestGet()` with t
620
620
621
621
``` php
622
622
$client->requestGet(
623
- \Redmine\Serializer\PathSerializer::create(
623
+ (string) \Redmine\Serializer\PathSerializer::create(
624
624
'/time_entries.json',
625
625
[
626
626
'f' => ['spent_on'],
@@ -632,7 +632,7 @@ $client->requestGet(
632
632
],
633
633
],
634
634
],
635
- )->getPath()
635
+ )
636
636
);
637
637
```
638
638
Original file line number Diff line number Diff line change 4
4
5
5
use JsonException ;
6
6
use Redmine \Exception \SerializerException ;
7
+ use Stringable ;
7
8
8
9
/**
9
10
* JsonSerializer.
10
11
*/
11
- final class JsonSerializer
12
+ final class JsonSerializer implements Stringable
12
13
{
13
14
/**
14
15
* @throws SerializerException if $data is not valid JSON
@@ -55,6 +56,11 @@ public function getEncoded(): string
55
56
return $ this ->encoded ;
56
57
}
57
58
59
+ public function __toString (): string
60
+ {
61
+ return $ this ->getEncoded ();
62
+ }
63
+
58
64
private function decode (string $ encoded ): void
59
65
{
60
66
$ this ->encoded = $ encoded ;
Original file line number Diff line number Diff line change 2
2
3
3
namespace Redmine \Serializer ;
4
4
5
+ use Stringable ;
6
+
5
7
/**
6
- * PathSerializer.
8
+ * PathSerializer to handle query parameters .
7
9
*/
8
- final class PathSerializer
10
+ final class PathSerializer implements Stringable
9
11
{
10
12
public static function create (string $ path , array $ queryParams = []): self
11
13
{
@@ -38,4 +40,9 @@ public function getPath(): string
38
40
39
41
return $ this ->path .$ queryString ;
40
42
}
43
+
44
+ public function __toString (): string
45
+ {
46
+ return $ this ->getPath ();
47
+ }
41
48
}
Original file line number Diff line number Diff line change 5
5
use JsonException ;
6
6
use Redmine \Exception \SerializerException ;
7
7
use SimpleXMLElement ;
8
+ use Stringable ;
8
9
use Throwable ;
9
10
10
11
/**
11
12
* XmlSerializer.
12
13
*/
13
- final class XmlSerializer
14
+ final class XmlSerializer implements Stringable
14
15
{
15
16
/**
16
17
* @throws SerializerException if $data is not valid XML
@@ -59,6 +60,11 @@ public function getEncoded(): string
59
60
return $ this ->encoded ;
60
61
}
61
62
63
+ public function __toString (): string
64
+ {
65
+ return $ this ->getEncoded ();
66
+ }
67
+
62
68
private function deserialize (string $ encoded ): void
63
69
{
64
70
$ this ->encoded = $ encoded ;
You can’t perform that action at this time.
0 commit comments