Code Duplication    Length = 23-23 lines in 2 locations

src/Request.php 1 location

@@ 181-203 (lines=23) @@
178
     *      @throws Exception\Runtime
179
     *      @return string
180
     */
181
    protected function own_private_key()
182
    {
183
        // check private key file
184
        if ( ! file_exists($this->jwt['our_privkey']))
185
        {
186
            throw new Exception\Runtime('The file with the private key was not find!');
187
        }
188
189
        // load private key file
190
        $fpkey = fopen($this->jwt['our_privkey'], "rb");
191
        if ($fpkey === FALSE)
192
        {
193
            throw new Exception\Runtime('The file with the private key was not open!');
194
        }
195
        $private_key = fread($fpkey, 8192);
196
        if ($private_key === FALSE)
197
        {
198
            throw new Exception\Runtime('The file with the private key was not read!');
199
        }
200
        fclose($fpkey);
201
202
        return $private_key;
203
    }
204
205
    /**
206
     *      Encode payload and return token

src/Response.php 1 location

@@ 106-128 (lines=23) @@
103
     *      @throws Exception\Runtime
104
     *      @return string Public key
105
     */
106
    protected function uapay_public_key()
107
    {
108
        // check public key file
109
        if ( ! file_exists($this->jwt['UAPAY_pubkey']))
110
        {
111
            throw new Exception\Runtime('The file with the public key was not find!');
112
        }
113
114
        // load public key file
115
        $fpkey = fopen($this->jwt['UAPAY_pubkey'], "rb");
116
        if ($fpkey === FALSE)
117
        {
118
            throw new Exception\Runtime('The file with the public key was not open!');
119
        }
120
        $public_key = fread($fpkey, 8192);
121
        if ($public_key === FALSE)
122
        {
123
            throw new Exception\Runtime('The file with the public key was not read!');
124
        }
125
        fclose($fpkey);
126
127
        return $public_key;
128
    }
129
130
    /**
131
     *      Decode token