Code Duplication    Length = 16-17 lines in 2 locations

src/Request.php 1 location

@@ 217-232 (lines=16) @@
214
     *      @throws Exception\JSON
215
     *      @return string Token
216
     */
217
    protected function token_encode($payload)
218
    {
219
        Log::instance()->debug('encode payload:');
220
        Log::instance()->debug(print_r($payload, true));
221
        try
222
        {
223
            $token = JWT::encode($payload, $this->own_private_key(), 'RS512');
224
        }
225
        catch (\Exception $e)
226
        {
227
            Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString());
228
            throw new Exception\JSON('unable to create JWT token', $e);
229
        }
230
231
        return $token;
232
    }
233
234
    /**
235
     *      Send request to UAPAY

src/Response.php 1 location

@@ 145-161 (lines=17) @@
142
     *      @throws Exception\Runtime
143
     *      @return array
144
     */
145
    protected function token_decode($token)
146
    {
147
        try
148
        {
149
            $decoded = (array) JWT::decode($token, $this->uapay_public_key(), array('RS512'));
150
        }
151
        catch (\Exception $e)
152
        {
153
            Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString());
154
            throw new Exception\JSON('unable to decode JWT token', $e);
155
        }
156
157
        Log::instance()->debug('decoded payload:');
158
        Log::instance()->debug(print_r($decoded, true));
159
160
        return $decoded;
161
    }
162
163
    /**
164
     *      Get status code