Code Duplication    Length = 8-10 lines in 4 locations

src/BlocktrailSDK.php 4 locations

@@ 829-838 (lines=10) @@
826
        $recoveryEncryptedSecret = null;
827
        $backupSeed = null;
828
829
        if (!isset($options['primary_private_key'])) {
830
            if (isset($options['primary_seed'])) {
831
                if (!$options['primary_seed'] instanceof BufferInterface) {
832
                    throw new \InvalidArgumentException('Primary Seed should be passed as a Buffer');
833
                }
834
                $primarySeed = $options['primary_seed'];
835
            } else {
836
                $primarySeed = new Buffer(self::randomBits(256));
837
            }
838
        }
839
840
        if ($storeDataOnServer) {
841
            if (!isset($options['secret'])) {
@@ 862-871 (lines=10) @@
859
            $recoveryEncryptedSecret = Encryption::encrypt($secret, $recoverySecret, KeyDerivation::DEFAULT_ITERATIONS);
860
        }
861
862
        if (!isset($options['backup_public_key'])) {
863
            if (isset($options['backup_seed'])) {
864
                if (!$options['backup_seed'] instanceof Buffer) {
865
                    throw new \RuntimeException('Backup seed must be an instance of Buffer');
866
                }
867
                $backupSeed = $options['backup_seed'];
868
            } else {
869
                $backupSeed = new Buffer(self::randomBits(256));
870
            }
871
        }
872
873
        if (isset($options['primary_private_key'])) {
874
            $options['primary_private_key'] = BlocktrailSDK::normalizeBIP32Key($options['primary_private_key']);
@@ 1140-1147 (lines=8) @@
1137
                );
1138
                break;
1139
            case Wallet::WALLET_VERSION_V3:
1140
                if (isset($options['encrypted_primary_seed'])) {
1141
                    if (!$options['encrypted_primary_seed'] instanceof Buffer) {
1142
                        throw new \InvalidArgumentException('Encrypted PrimarySeed must be provided as a Buffer');
1143
                    }
1144
                    $encryptedPrimarySeed = $data['encrypted_primary_seed'];
1145
                } else {
1146
                    $encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed']));
1147
                }
1148
1149
                if (isset($options['encrypted_secret'])) {
1150
                    if (!$options['encrypted_secret'] instanceof Buffer) {
@@ 1149-1157 (lines=9) @@
1146
                    $encryptedPrimarySeed = new Buffer(base64_decode($data['encrypted_primary_seed']));
1147
                }
1148
1149
                if (isset($options['encrypted_secret'])) {
1150
                    if (!$options['encrypted_secret'] instanceof Buffer) {
1151
                        throw new \InvalidArgumentException('Encrypted secret must be provided as a Buffer');
1152
                    }
1153
1154
                    $encryptedSecret = $data['encrypted_secret'];
1155
                } else {
1156
                    $encryptedSecret = new Buffer(base64_decode($data['encrypted_secret']));
1157
                }
1158
1159
                $wallet = new WalletV3(
1160
                    $this,