File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,11 @@ public function __construct(array $data = array())
50
50
*/
51
51
public function summarizeText (string $ text ): stdClass
52
52
{
53
- return $ this ->requester ->post ($ this ->buildUrl (), array (
53
+ $ summary = $ this ->requester ->post ($ this ->buildUrl (), array (
54
54
'sm_api_input ' => $ text ,
55
55
));
56
+
57
+ return $ this ->cleanSummary ($ summary );
56
58
}
57
59
58
60
/**
@@ -64,7 +66,9 @@ public function summarizeText(string $text): stdClass
64
66
*/
65
67
public function summarizeUrl (string $ url ): stdClass
66
68
{
67
- return $ this ->requester ->get ($ this ->buildUrl (array ('SM_URL ' => $ url )));
69
+ $ summary = $ this ->requester ->get ($ this ->buildUrl (array ('SM_URL ' => $ url )));
70
+
71
+ return $ this ->cleanSummary ($ summary );
68
72
}
69
73
70
74
/**
@@ -102,4 +106,19 @@ protected function buildUrl(array $data = array()): string
102
106
103
107
return $ url ;
104
108
}
109
+
110
+ /**
111
+ * Cleans summary response values.
112
+ *
113
+ * @param stdClass $summary The summary response to clean.
114
+ *
115
+ * @return stdClass
116
+ */
117
+ protected function cleanSummary (stdClass $ summary )
118
+ {
119
+ $ summary ->sm_api_title = trim ($ summary ->sm_api_title );
120
+ $ summary ->sm_api_content = trim ($ summary ->sm_api_content );
121
+
122
+ return $ summary ;
123
+ }
105
124
}
You can’t perform that action at this time.
0 commit comments