Code Duplication    Length = 18-19 lines in 2 locations

src/Signer/OpenSSL/PrivateKey.php 1 location

@@ 8-26 (lines=19) @@
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
final class PrivateKey extends Key
9
{
10
    /**
11
     * @param mixed       $value
12
     * @param string|null $passphrase
13
     */
14
    public function __construct($value, $passphrase = null)
15
    {
16
        if (is_string($value) && is_file($value) && is_readable($value)) {
17
            $value = file_get_contents($value);
18
        }
19
20
        if (!is_resource($value)) {
21
            $value = openssl_pkey_get_private($value, $passphrase);
22
        }
23
24
        parent::__construct($value);
25
    }
26
}
27

src/Signer/OpenSSL/PublicKey.php 1 location

@@ 8-25 (lines=18) @@
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
final class PublicKey extends Key
9
{
10
    /**
11
     * @param mixed $value
12
     */
13
    public function __construct($value)
14
    {
15
        if (is_string($value) && is_file($value) && is_readable($value)) {
16
            $value = file_get_contents($value);
17
        }
18
19
        if (!is_resource($value)) {
20
            $value = openssl_pkey_get_public($value);
21
        }
22
23
        parent::__construct($value);
24
    }
25
}
26