@@ -34,37 +34,38 @@ class API extends AbstractAPI
3434 public function __construct (Signature $ signature , $ classify , $ filter )
3535 {
3636 $ this ->signature = $ signature ;
37- $ this ->classify = $ classify ;
38- $ this ->filter = $ filter ;
37+ $ this ->classify = $ classify ;
38+ $ this ->filter = $ filter ;
3939 }
4040
4141 /**
4242 * 请求API.
4343 *
4444 * @param string $method
45- * @param array $params
46- * @param array $files
45+ * @param array $params
46+ * @param array $files
4747 *
48+ * @return array
4849 * @throws NotFoundException
4950 * @throws IllegalParameterException
5051 *
51- * @return array
52+ * @throws IllegalParameterException
5253 */
5354 public function request ($ method , $ params = [], $ files = [])
5455 {
5556 $ url = sprintf ('%s/%s/%s_%s ' , self ::BASE_API , $ this ->classify , $ this ->classify , strtolower ($ method ));
5657 if (!array_key_exists (strtolower ($ method ), $ this ->filter )) {
5758 throw new NotFoundException (sprintf ('the url %s can not found!please reaffirm ' , $ url ));
5859 }
59- $ factory = new ValidatorFactory (new Translator ());
60+ $ factory = new ValidatorFactory (new Translator ());
6061 $ validator = $ factory ->make ($ params , $ this ->filter [$ method ]);
6162 if (!$ validator ->passes ()) {
6263 throw new IllegalParameterException (sprintf ('参数错误:[%s] ' , json_encode ($ validator ->errors (), JSON_UNESCAPED_UNICODE )));
6364 }
64- $ http = $ this ->getHttp ();
65- $ params = $ this ->processParams ($ this ->signature , $ params );
65+ $ http = $ this ->getHttp ();
66+ $ params = $ this ->processParams ($ this ->signature , $ params );
6667 $ response = $ files ? $ http ->upload ($ url , $ params , $ files ) : $ http ->post ($ url , $ params );
67- $ result = json_decode (strval ($ response ->getBody ()), true );
68+ $ result = json_decode (strval ($ response ->getBody ()), true );
6869 if (isset ($ result ['ret ' ])) {
6970 return $ result ;
7071 }
0 commit comments