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

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