File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,26 +56,36 @@ public function __call($name, $arguments)
5656 throw new BadMethodCallException (sprintf ('The method [%s::%s] does not exist. ' , static ::class, $ name ));
5757 }
5858
59- public function setOptions ( array $ options ): self
59+ public function setOption ( string $ option , $ value ): self
6060 {
61- $ this ->options = array_merge ( $ this -> options , $ options ) ;
61+ $ this ->options [ $ option ] = $ value ;
6262
6363 return $ this ;
6464 }
6565
66- public function setOption ( string $ option , $ value ): self
66+ public function setOptions ( array $ options ): self
6767 {
68- $ this ->options [ $ option ] = $ value ;
68+ $ this ->options = array_merge ( $ this -> options , $ options ) ;
6969
7070 return $ this ;
7171 }
7272
7373 public function getOption (string $ option , $ default = null )
7474 {
75- return $ this ->getOptions () [$ option ] ?? $ default ;
75+ return $ this ->options [$ option ] ?? $ default ;
7676 }
7777
7878 public function getOptions (): array
79+ {
80+ return $ this ->options ;
81+ }
82+
83+ public function getValidatedOption (string $ option , $ default = null )
84+ {
85+ return $ this ->getValidatedOptions ()[$ option ] ?? $ default ;
86+ }
87+
88+ public function getValidatedOptions (): array
7989 {
8090 return $ this ->configureAndResolveOptions ($ this ->options , function (OptionsResolver $ optionsResolver ): void {
8191 $ this ->preConfigureOptionsResolver ($ optionsResolver );
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ public static function make($options = []): self
7171
7272 protected function toPayload (): array
7373 {
74- return Arr::rejectRecursive ($ this ->getOptions (), static fn ($ value ): bool => [] === $ value || null === $ value );
74+ return Arr::rejectRecursive ($ this ->getValidatedOptions (), static fn ($ value ): bool => [] === $ value || null === $ value );
7575 }
7676
7777 protected function toJson (int $ options = JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE ): string
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public function toHttpOptions(): array
2929 RequestOptions::JSON => [
3030 'msgtype ' => $ this ->type (),
3131 $ this ->type () => [
32- 'base64 ' => base64_encode_file ($ image = $ this ->getOption ('image ' )),
32+ 'base64 ' => base64_encode_file ($ image = $ this ->getValidatedOption ('image ' )),
3333 'md5 ' => md5_file ($ image ),
3434 ],
3535 ],
You can’t perform that action at this time.
0 commit comments