Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Sep 7, 2024
1 parent 66d9454 commit ada317a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/Events/AllTranslationsHasBeenForgetEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class AllTranslationsHasBeenForgetEvent

public function __construct(
public Model $model
) {}
) {
}
}
3 changes: 2 additions & 1 deletion src/Events/TranslationHasBeenForgetEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class TranslationHasBeenForgetEvent
public function __construct(
public Model $model,
public ?Locale $locale
) {}
) {
}
}
3 changes: 2 additions & 1 deletion src/Events/TranslationHasBeenSetEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public function __construct(
public ?Locale $locale,
public mixed $oldValue,
public mixed $newValue,
) {}
) {
}
}
7 changes: 5 additions & 2 deletions src/Generators/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ abstract protected function filename(): string;
public function __construct(
protected string $model,
protected array $columns
) {}
) {
}

public static function of(string $model, array $columns = []): static
{
Expand All @@ -54,7 +55,9 @@ protected function make(): string
->toString();
}

protected function finish(string $path): void {}
protected function finish(string $path): void
{
}

protected function baseData(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function data(): array
protected function filename(): string
{
$directory = dirname($path = $this->path());
$filename = $this->getModel() . $this->modelSuffix();
$filename = $this->getModel() . $this->modelSuffix();
$extension = $this->extension($path);

return $directory . '/' . $filename . '.' . $extension;
Expand Down
2 changes: 1 addition & 1 deletion src/HasTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function setRelation($relation, $value): static

public function newInstance($attributes = [], $exists = false): static
{
$basic = Arr::except($attributes, $this->translatable());
$basic = Arr::except($attributes, $this->translatable());
$translatable = Arr::only($attributes, $this->translatable());

$model = parent::newInstance($basic, $exists);
Expand Down
3 changes: 2 additions & 1 deletion src/Services/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function __construct(
protected EloquentModel $model,
protected ?string $column = null,
protected Locale|LocaleData|string|null $locale = null
) {}
) {
}

public static function of(
EloquentModel $model,
Expand Down
8 changes: 4 additions & 4 deletions tests/Constants/FakeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class FakeValue
{
public const ColumnDescription = 'description';
public const ColumnTitle = 'title';
public const LocaleCustom = 'as';
public const LocaleFallback = 'de';
public const LocaleMain = 'fr';
public const ColumnTitle = 'title';
public const LocaleCustom = 'as';
public const LocaleFallback = 'de';
public const LocaleMain = 'fr';
public const LocaleUninstalled = 'af';
}
2 changes: 1 addition & 1 deletion tests/Unit/Console/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'--columns' => ['title', 'description'],
])->run();

$model = base_path('app/Models/SomeTranslation.php');
$model = base_path('app/Models/SomeTranslation.php');
$helper = sprintf('%s/_ide_helper_models_%s.php', Config::shared()->models->helpers, md5('App\Models\Some'));

$migrations = File::allPaths(database_path('migrations'), fn (string $path) => Path::extension($path) === 'php');
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Events/TranslationHasBeenForgetEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

Event::assertDispatched(function (TranslationHasBeenForgetEvent $event) use ($model) {
return $event->model->getKey() === $model->getKey()
&& $event->locale === Locale::French;
&& $event->locale === Locale::French;
});
});
32 changes: 16 additions & 16 deletions tests/Unit/Events/TranslationHasBeenSetEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

Event::assertDispatched(function (TranslationHasBeenSetEvent $event) use ($model, $oldText, $newText) {
return $event->model->getKey() === $model->getKey()
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === null
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === null
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
});
});

Expand All @@ -38,10 +38,10 @@

Event::assertDispatched(function (TranslationHasBeenSetEvent $event) use ($model, $oldText, $newText) {
return $event->model->getKey() === $model->getKey()
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === Locale::French
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === Locale::French
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
});
});

Expand All @@ -55,10 +55,10 @@

Event::assertDispatched(function (TranslationHasBeenSetEvent $event) use ($model, $oldText, $newText) {
return $event->model->getKey() === $model->getKey()
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === Locale::German
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === Locale::German
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
});
});

Expand All @@ -72,9 +72,9 @@

Event::assertDispatched(function (TranslationHasBeenSetEvent $event) use ($model, $oldText, $newText) {
return $event->model->getKey() === $model->getKey()
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === Locale::Assamese
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
&& $event->column === FakeValue::ColumnTitle
&& $event->locale === Locale::Assamese
&& $event->oldValue === $oldText
&& $event->newValue === $newText;
});
});
2 changes: 1 addition & 1 deletion tests/Unit/Models/GetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
config()->set(Name::Shared() . '.models.filter.enabled', $enabled);

$hasNonFilteredQuery = false;
$hasFilteredQuery = false;
$hasFilteredQuery = false;

DB::listen(function (QueryExecuted $query) use (&$hasNonFilteredQuery, &$hasFilteredQuery) {
if (Str::is('select * where *."item_id" = ? and *."item_id" is not null', $query->sql)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class extends Migration
{
public function up(): void
{
Schema::create('test_models', function (Blueprint $table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class extends Migration
{
public function up(): void
{
Schema::create('test_model_translations', function (Blueprint $table) {
Expand Down

0 comments on commit ada317a

Please sign in to comment.