88class TextRuApi
99{
1010
11+ /**
12+ * @var
13+ */
1114 private $ userkey ;
15+ private $ default_options ;
1216
1317 private static $ allowed_options_get = ["exceptdomain " , "excepturl " , "visible " , "copying " , "callback " ];
1418
@@ -22,6 +26,11 @@ public function __construct($userkey, $default_options = [])
2226 $ this ->default_options = $ default_options ;
2327 }
2428
29+ /**
30+ * Return $userkey or set $userkey if param provided
31+ * @param null $userkey
32+ * @return $this
33+ */
2534 public function userkey ($ userkey = null )
2635 {
2736 if (is_null ($ userkey )) return $ this ->userkey ;
@@ -31,6 +40,14 @@ public function userkey($userkey = null)
3140 return $ this ;
3241 }
3342
43+ /**
44+ * Send API add request to TextRu
45+ * @param $userkey
46+ * @param $text
47+ * @param array $options
48+ * @return array
49+ * @throws WrongParameterException
50+ */
3451 public static function add ($ userkey , $ text , $ options = [])
3552 {
3653 if ((empty ($ userkey )) || (empty ($ text ))) throw new WrongParameterException ("Required params is empty " , 400123 );
@@ -64,6 +81,14 @@ public function adds($text, $options = [])
6481 return $ this ::add ($ this ->userkey , $ text , $ options );
6582 }
6683
84+ /**
85+ * Send API get request to TextRu
86+ * @param $userkey
87+ * @param $uid
88+ * @param null $jsonvisible
89+ * @return array
90+ * @throws WrongParameterException
91+ */
6792 public static function get ($ userkey , $ uid , $ jsonvisible = null )
6893 {
6994 if ((empty ($ userkey )) || (empty ($ uid ))) throw new WrongParameterException ("Required params is empty " , 400131 );
@@ -97,6 +122,13 @@ public static function gets($uid, $jsonvisible = null)
97122 return $ this ::add ($ this ->userkey , $ uid , $ jsonvisible );
98123 }
99124
125+ /**
126+ * Curl wrapper, send POST request with predefined settings
127+ * @param $postfields
128+ * @param string $url
129+ * @return mixed
130+ * @throws CurlRequestException
131+ */
100132 public static function sendCurl ($ postfields , $ url = 'http://api.text.ru/post ' )
101133 {
102134 if (is_array ($ postfields )) $ postfields = http_build_query ($ postfields , '' , '& ' );
0 commit comments