Code Duplication    Length = 18-19 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

@@ 57-75 (lines=19) @@
54
    /**
55
     * {@inheritdoc}.
56
     */
57
    public function getTokenFromServer()
58
    {
59
        $data = [
60
            'component_appid' => $this->appId,
61
            'component_appsecret' => $this->secret,
62
            'component_verify_ticket' => $this->getComponentVerifyTicket(),
63
        ];
64
65
        $http = $this->getHttp();
66
67
        $token = $http->parseJSON($http->json(self::API_TOKEN_GET, $data));
68
69
        if (empty($token[$this->tokenJsonKey])) {
70
            throw new HttpException('Request ComponentAccessToken fail. response: '.json_encode($token, JSON_UNESCAPED_UNICODE));
71
        }
72
73
        return $token;
74
    }
75
76
    /**
77
     * Get component verify ticket.
78
     *