Code Duplication    Length = 18-18 lines in 2 locations

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

src/Core/AccessToken.php 1 location

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