Code Duplication    Length = 8-10 lines in 4 locations

src/BlocktrailSDK.php 4 locations

@@ 853-862 (lines=10) @@
850
        $recoveryEncryptedSecret = null;
851
        $backupSeed = null;
852
853
        if (!isset($options['primary_private_key'])) {
854
            if (isset($options['primary_seed'])) {
855
                if (!$options['primary_seed'] instanceof BufferInterface) {
856
                    throw new \InvalidArgumentException('Primary Seed should be passed as a Buffer');
857
                }
858
                $primarySeed = $options['primary_seed'];
859
            } else {
860
                $primarySeed = new Buffer(self::randomBits(256));
861
            }
862
        }
863
864
        if ($storeDataOnServer) {
865
            if (!isset($options['secret'])) {
@@ 886-895 (lines=10) @@
883
            $recoveryEncryptedSecret = Encryption::encrypt($secret, $recoverySecret, KeyDerivation::DEFAULT_ITERATIONS);
884
        }
885
886
        if (!isset($options['backup_public_key'])) {
887
            if (isset($options['backup_seed'])) {
888
                if (!$options['backup_seed'] instanceof Buffer) {
889
                    throw new \RuntimeException('Backup seed must be an instance of Buffer');
890
                }
891
                $backupSeed = $options['backup_seed'];
892
            } else {
893
                $backupSeed = new Buffer(self::randomBits(256));
894
            }
895
        }
896
897
        if (isset($options['primary_private_key'])) {
898
            $options['primary_private_key'] = BlocktrailSDK::normalizeBIP32Key($options['primary_private_key']);
@@ 1164-1171 (lines=8) @@
1161
                );
1162
                break;
1163
            case Wallet::WALLET_VERSION_V3:
1164
                if (isset($options['encrypted_primary_seed'])) {
1165
                    if (!$options['encrypted_primary_seed'] instanceof Buffer) {
1166
                        throw new \InvalidArgumentException('Encrypted PrimarySeed must be provided as a Buffer');
1167
                    }
1168
                    $encryptedPrimarySeed = $data['encrypted_primary_seed'];
1169
                } else {
1170
                    $encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed']));
1171
                }
1172
1173
                if (isset($options['encrypted_secret'])) {
1174
                    if (!$options['encrypted_secret'] instanceof Buffer) {
@@ 1173-1181 (lines=9) @@
1170
                    $encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed']));
1171
                }
1172
1173
                if (isset($options['encrypted_secret'])) {
1174
                    if (!$options['encrypted_secret'] instanceof Buffer) {
1175
                        throw new \InvalidArgumentException('Encrypted secret must be provided as a Buffer');
1176
                    }
1177
1178
                    $encryptedSecret = $data['encrypted_secret'];
1179
                } else {
1180
                    $encryptedSecret = new Buffer(base64_decode($data['encrypted_secret']));
1181
                }
1182
1183
                $wallet = new WalletV3(
1184
                    $this,