File tree 2 files changed +15
-15
lines changed
src/Messages/MessageObjects
2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 6
6
7
7
class AudioObject implements ArrayHydrateInterface
8
8
{
9
- public function __construct (private string $ url , private string $ caption = '' )
9
+ /**
10
+ * Legacy to pass in a caption as this should never have been supported. Nothing will happen if you pass one in.
11
+ */
12
+ public function __construct (private string $ url , private readonly ?string $ caption = null )
10
13
{
11
14
}
12
15
13
16
public function fromArray (array $ data ): AudioObject
14
17
{
15
18
$ this ->url = $ data ['url ' ];
16
19
17
- if (isset ($ data ['caption ' ])) {
18
- $ this ->caption = $ data ['caption ' ];
19
- }
20
-
21
20
return $ this ;
22
21
}
23
22
24
23
public function toArray (): array
25
24
{
26
- $ returnArray = [
25
+ return [
27
26
'url ' => $ this ->url
28
27
];
29
-
30
- if ($ this ->caption ) {
31
- $ returnArray [] = [
32
- 'caption ' => $ this ->caption
33
- ];
34
- }
35
-
36
- return $ returnArray ;
37
28
}
38
29
39
30
public function getUrl (): string
40
31
{
41
32
return $ this ->url ;
42
33
}
43
34
35
+ /**
36
+ * @deprecated Unsupported
37
+ * @return string
38
+ */
44
39
public function getCaption (): string
45
40
{
41
+ trigger_error (
42
+ 'Captions are not supported in this API, this will error at server level. ' ,
43
+ E_USER_DEPRECATED
44
+ );
45
+
46
46
return $ this ->caption ;
47
47
}
48
48
}
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ public function testCanSendWhatsAppAudio(): void
376
376
{
377
377
$ audioObject = new AudioObject (
378
378
'https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3 ' ,
379
- ' some audio '
379
+ null
380
380
);
381
381
382
382
$ payload = [
You can’t perform that action at this time.
0 commit comments