File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- namespace ZhenMu \Support \Traits ;
3+ /*
4+ * Fresns (https://fresns.org)
5+ * Copyright (C) 2021-Present Jarvis Tang
6+ */
7+
8+ namespace Plugins \FresnsEngine ;
49
510trait Clientable
611{
@@ -36,20 +41,19 @@ abstract public function getLastPage(): ?int;
3641
3742 abstract public function getDataList (): static |array |null ;
3843
39- protected function castResponse ()
44+ public function castResponse ()
4045 {
41- $ this ->result = json_decode ($ content = $ this ->response ->getBody ()->getContents (), true ) ?? [];
42- $ this ->attributes = $ this ->result ;
46+ $ result = json_decode ($ content = $ this ->response ->getBody ()->getContents (), true ) ?? [];
4347
44- if (empty ($ this -> result )) {
48+ if (empty ($ result )) {
4549 $ this ->handleEmptyResponse ($ content );
4650 }
4751
4852 if ($ this ->isErrorResponse ()) {
4953 $ this ->handleErrorResponse ($ content );
5054 }
5155
52- return true ;
56+ return $ result ;
5357 }
5458
5559 public function paginate ()
@@ -77,7 +81,9 @@ public function __call($method, $args)
7781 {
7882 $ this ->response = $ this ->getHttpClient ()->$ method (...$ args );
7983
80- $ this ->castResponse ();
84+ $ this ->result = $ this ->castResponse ();
85+
86+ $ this ->attributes = $ this ->result ;
8187
8288 return $ this ;
8389 }
You can’t perform that action at this time.
0 commit comments