Code Duplication    Length = 18-18 lines in 2 locations

src/Core/AccessToken.php 1 location

@@ 230-247 (lines=18) @@
227
     *
228
     * @return string
229
     */
230
    public function getTokenFromServer()
231
    {
232
        $params = [
233
            'appid' => $this->appId,
234
            'secret' => $this->secret,
235
            'grant_type' => 'client_credential',
236
        ];
237
238
        $http = $this->getHttp();
239
240
        $token = $http->parseJSON($http->get(self::API_TOKEN_GET, $params));
241
242
        if (empty($token[$this->tokenJsonKey])) {
243
            throw new HttpException('Request AccessToken fail. response: '.json_encode($token, JSON_UNESCAPED_UNICODE));
244
        }
245
246
        return $token;
247
    }
248
249
    /**
250
     * Return the http instance.

src/OpenPlatform/AccessToken.php 1 location

@@ 78-95 (lines=18) @@
75
    /**
76
     * {@inheritdoc}.
77
     */
78
    public function getTokenFromServer()
79
    {
80
        $data = [
81
            'component_appid' => $this->appId,
82
            'component_appsecret' => $this->secret,
83
            'component_verify_ticket' => $this->verifyTicket->getTicket(),
84
        ];
85
86
        $http = $this->getHttp();
87
88
        $token = $http->parseJSON($http->json(self::API_TOKEN_GET, $data));
89
90
        if (empty($token[$this->tokenJsonKey])) {
91
            throw new HttpException('Request ComponentAccessToken fail. response: '.json_encode($token, JSON_UNESCAPED_UNICODE));
92
        }
93
94
        return $token;
95
    }
96
}
97