Code Duplication    Length = 16-17 lines in 2 locations

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

src/Request.php 1 location

@@ 195-210 (lines=16) @@
192
     *      @throws Exception\JSON
193
     *      @return string Token
194
     */
195
    protected function token_encode($payload)
196
    {
197
        Log::instance()->debug('encode payload:');
198
        Log::instance()->debug(print_r($payload, true));
199
        try
200
        {
201
            $token = JWT::encode($payload, $this->own_private_key(), 'RS512');
202
        }
203
        catch (\Exception $e)
204
        {
205
            Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString());
206
            throw new Exception\JSON('unable to create JWT token', $e);
207
        }
208
209
        return $token;
210
    }
211
212
    /**
213
     *      Send request to UAPAY