File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed
src/Messages/MessageObjects Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 66
77class AudioObject implements ArrayHydrateInterface
88{
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 )
1013 {
1114 }
1215
1316 public function fromArray (array $ data ): AudioObject
1417 {
1518 $ this ->url = $ data ['url ' ];
1619
17- if (isset ($ data ['caption ' ])) {
18- $ this ->caption = $ data ['caption ' ];
19- }
20-
2120 return $ this ;
2221 }
2322
2423 public function toArray (): array
2524 {
26- $ returnArray = [
25+ return [
2726 'url ' => $ this ->url
2827 ];
29-
30- if ($ this ->caption ) {
31- $ returnArray [] = [
32- 'caption ' => $ this ->caption
33- ];
34- }
35-
36- return $ returnArray ;
3728 }
3829
3930 public function getUrl (): string
4031 {
4132 return $ this ->url ;
4233 }
4334
35+ /**
36+ * @deprecated Unsupported
37+ * @return string
38+ */
4439 public function getCaption (): string
4540 {
41+ trigger_error (
42+ 'Captions are not supported in this API, this will error at server level. ' ,
43+ E_USER_DEPRECATED
44+ );
45+
4646 return $ this ->caption ;
4747 }
4848}
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ public function testCanSendWhatsAppAudio(): void
376376 {
377377 $ audioObject = new AudioObject (
378378 'https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3 ' ,
379- ' some audio '
379+ null
380380 );
381381
382382 $ payload = [
You can’t perform that action at this time.
0 commit comments