Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6 from austinheap/analysis-qx4JWB
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
austinheap committed Dec 13, 2017
2 parents 0d9e708 + d6f94d4 commit 2017ef3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Console/Commands/MigrateEncryptionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
* @author Austin Heap <me@austinheap.com>
* @version v0.1.0
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\Encryption\Console\Commands;

use RuntimeException;
use DatabaseEncryption;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use RuntimeException;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Config;

/**
* Class MigrateEncryptionCommand.
Expand Down Expand Up @@ -96,7 +96,7 @@ protected function getEncryptionPrefix(): string
*/
protected function isEncrypted($value): bool
{
return strpos((string)$value, $this->getEncryptionPrefix()) === 0;
return strpos((string) $value, $this->getEncryptionPrefix()) === 0;
}

/**
Expand All @@ -109,7 +109,7 @@ protected function isEncrypted($value): bool
*/
public function encryptedAttribute($value, $cipher): ?string
{
return $this->getEncryptionPrefix() . $cipher->encrypt($value);
return $this->getEncryptionPrefix().$cipher->encrypt($value);
}

/**
Expand Down Expand Up @@ -152,22 +152,22 @@ public function handle()
// Check that the keys have been set up
throw_if(empty($this->old_keys) || count($this->old_keys) == 0, RuntimeException::class,
'You must override this class with (array)$old_keys set correctly.');
throw_if(empty($this->new_key) || !is_string($this->new_key), RuntimeException::class,
throw_if(empty($this->new_key) || ! is_string($this->new_key), RuntimeException::class,
'You must override this class with (string)$new_key set correctly.');
throw_if(empty($this->tables) || count($this->tables) == 0, RuntimeException::class,
'You must override this class with (array)$tables set correctly.');

// Make some encrypter objects
$cipher = Config::get('app.cipher');
$cipher = Config::get('app.cipher');
$baseEncrypter = new Encrypter($this->new_key, $cipher);
$oldEncrypter = [];
$oldEncrypter = [];

foreach ($this->old_keys as $key => $value) {
$oldEncrypter[$key] = new Encrypter($value, $cipher);
}

foreach ($this->tables as $table_name) {
$this->comment('Fetching data from: ' . $table_name);
$this->comment('Fetching data from: '.$table_name);

// Get count of records
$count = DB::table($table_name)
Expand All @@ -177,7 +177,7 @@ public function handle()
$bar = $this->output->createProgressBar($count);

$count = number_format($count, 0, '.', ',');
$this->comment('Found ' . number_format($count, 0) . ' records in database; checking encryption keys.');
$this->comment('Found '.number_format($count, 0).' records in database; checking encryption keys.');

// Get a table object
$table_data = DB::table($table_name);
Expand All @@ -192,7 +192,7 @@ public function handle()
// encrypted then try to decrypt it with the base encrypter.
$adjust = [];
foreach ($datum_array as $key => $value) {
if (!$this->isEncrypted($value)) {
if (! $this->isEncrypted($value)) {
continue;
}

Expand Down Expand Up @@ -222,8 +222,8 @@ public function handle()
// If we got a match then we will have something in $new_value
if (empty($new_value)) {
Log::error(
__CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' .
'Unable to find encryption key for: ' . $table_name->key . ' #' . $datum->id
__CLASS__.':'.__TRAIT__.':'.__FILE__.':'.__LINE__.':'.__FUNCTION__.':'.
'Unable to find encryption key for: '.$table_name->key.' #'.$datum->id
);

continue;
Expand Down

0 comments on commit 2017ef3

Please sign in to comment.