Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sairahcaz authored and github-actions[bot] committed Feb 24, 2023
1 parent df39de8 commit 2bc90fe
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
4 changes: 2 additions & 2 deletions config/useful-traits.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
"refresh_db_fast" => [
'refresh_db_fast' => [
/**
* This field determines if the database should be seeded after migration.
*/
"seed" => env('USEFUL_TRAITS_SEED_AFTER_FAST_DB_REFRESH', false),
'seed' => env('USEFUL_TRAITS_SEED_AFTER_FAST_DB_REFRESH', false),
],
];
3 changes: 1 addition & 2 deletions src/LaravelUsefulTraitsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function configurePackage(Package $package): void
*/
$package
->name('laravel-useful-traits')
->hasConfigFile()
;
->hasConfigFile();
}
}
23 changes: 6 additions & 17 deletions src/RefreshDatabaseFast.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Only migrate fresh if necessary -> much faster after first time!
* Credits to mayahi, with some small changes of mine.
*
* @link https://mayahi.net/laravel/make-refresh-database-trait-much-faster/
*/
trait RefreshDatabaseFast
Expand All @@ -18,8 +19,6 @@ trait RefreshDatabaseFast

/**
* Only migrates fresh if necessary
*
* @return void
*/
protected function refreshTestDatabase(): void
{
Expand All @@ -37,12 +36,10 @@ protected function refreshTestDatabase(): void
/**
* Check if migration fresh is necessary by checking
* if the migrations files checksum has changed.
*
* @return void
*/
protected function runMigrationsIfNecessary(): void
{
if (!$this->identicalChecksum()) {
if (! $this->identicalChecksum()) {
if (config('useful-traits.refresh_db_fast.seed')) {
$this->seed();
}
Expand All @@ -56,8 +53,6 @@ protected function runMigrationsIfNecessary(): void

/**
* Calaculates the checksum of the migration files.
*
* @return string
*/
private function calculateChecksum(): string
{
Expand All @@ -74,15 +69,15 @@ private function calculateChecksum(): string

$files = array_keys(iterator_to_array($files));

$checksum = collect($files)->map(function($file) {return md5_file($file);})->implode('');
$checksum = collect($files)->map(function ($file) {
return md5_file($file);
})->implode('');

return md5($checksum);
}

/**
* Filepath to store the checksum.
*
* @return string
*/
private function checksumFilePath(): string
{
Expand All @@ -91,8 +86,6 @@ private function checksumFilePath(): string

/**
* Creates the checksum file.
*
* @return void
*/
private function createChecksum(): void
{
Expand All @@ -111,8 +104,6 @@ private function checksumFileContents()

/**
* Check if checksum exists.
*
* @return bool
*/
private function isChecksumExists(): bool
{
Expand All @@ -122,12 +113,10 @@ private function isChecksumExists(): bool
/**
* Check if checksum of current database migration files
* are identical to the one we stored already.
*
* @return bool
*/
private function identicalChecksum(): bool
{
if (!$this->isChecksumExists()) {
if (! $this->isChecksumExists()) {
return false;
}

Expand Down
5 changes: 0 additions & 5 deletions src/UsefulScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ trait UsefulScopes
{
/**
* Scope a query to only exclude specific Columns.
*
* @param Builder $query
* @param $excludeColumns
* @return Builder
*/
public function scopeSelectAllBut(Builder $query, array $excludeColumns): Builder
{
Expand All @@ -35,7 +31,6 @@ public function scopeSelectAllBut(Builder $query, array $excludeColumns): Builde
* modifying the contents of files inside the migrations directory will not re-cache the columns
* Whenever you make a new deployment/migration you can clear the cache.
*
* @return array
**/
public function getTableColumns(): array
{
Expand Down
1 change: 0 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Illuminate\Foundation\Testing\RefreshDatabase;
use LaracraftTech\LaravelUsefulTraits\RefreshDatabaseFast;
use LaracraftTech\LaravelUsefulTraits\Tests\TestCase;

Expand Down

0 comments on commit 2bc90fe

Please sign in to comment.