Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach authored and github-actions[bot] committed Sep 23, 2024
1 parent 745511e commit 39125d5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Attributes/AttributeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function forModel(string|Model $model): Collection
$model = new $model;
}

return (new self())->attributes($model);
return (new self)->attributes($model);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Relations/RelationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function forModel(string|Model $model): Collection
$model = new $model;
}

return (new self())->relations($model);
return (new self)->relations($model);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions tests/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function Spatie\Snapshots\assertMatchesSnapshot;

it('can get the attributes of a model', function () {
$attributes = AttributeFinder::forModel(new TestModel());
$attributes = AttributeFinder::forModel(new TestModel);

expect($attributes)->toHaveCount(12);

Expand All @@ -21,7 +21,7 @@
* @see https://laravel.com/docs/8.x/eloquent-mutators#defining-an-accessor
*/
it('can get the accessor attributes of a model', function () {
$attributes = AttributeFinder::forModel(new TestModel());
$attributes = AttributeFinder::forModel(new TestModel);

$titleUppercaseAttr = $attributes->first(fn ($attr) => $attr->name === 'title_uppercase');
$titleWithoutReturnTypeAttr = $attributes->first(fn ($attr) => $attr->name === 'title_without_return_type');
Expand All @@ -40,7 +40,7 @@
* @see https://laravel.com/docs/8.x/eloquent-mutators#defining-a-mutator
*/
it('can get the mutator attributes of a model', function () {
$attributes = AttributeFinder::forModel(new TestModel());
$attributes = AttributeFinder::forModel(new TestModel);

$passwordMutatorAttr = $attributes->first(fn ($attr) => $attr->name === 'encrypted_password');
$passwordMutatorWithoutTypeHintAttr = $attributes->first(fn ($attr) => $attr->name === 'trimmed_and_encrypted_password');
Expand All @@ -56,7 +56,7 @@
});

it('can handle accessor-mutator combinations', function () {
$attributes = AttributeFinder::forModel(new TestModel());
$attributes = AttributeFinder::forModel(new TestModel);

$dottedNameAttr = $attributes->first(fn ($attr) => $attr->name === 'dotted_name');

Expand All @@ -72,7 +72,7 @@
* @see https://laravel.com/docs/9.x/eloquent-mutators#accessors-and-mutators
*/
it('can handle virtual attributes of a model', function () {
$attributes = AttributeFinder::forModel(new TestModel());
$attributes = AttributeFinder::forModel(new TestModel);

$titleLowercaseAttr = $attributes->first(fn ($attr) => $attr->name === 'title_lowercase');

Expand All @@ -83,15 +83,15 @@
});

it('can get extended column types for a model', function () {
$attributes = AttributeFinder::forModel(new ExtendedTypesModel());
$attributes = AttributeFinder::forModel(new ExtendedTypesModel);

expect($attributes)->toHaveCount(6);

matchesAttributesSnapshot($attributes);
});

it('retrieves phpType attribute from cast and falls back to column type', function () {
$attributes = AttributeFinder::forModel(new PhpTypeFromCastModel());
$attributes = AttributeFinder::forModel(new PhpTypeFromCastModel);

expect($attributes->pluck('phpType')->toArray())->toBe([
'array',
Expand Down
6 changes: 3 additions & 3 deletions tests/RelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
use Spatie\ModelInfo\Tests\TestSupport\Models\TestModel;

it('can find the relations on a model', function () {
$relations = RelationFinder::forModel(new RelationTestModel());
$relations = RelationFinder::forModel(new RelationTestModel);

expect($relations)->toHaveCount(1);
});

it('will find no relations on a model that has none', function () {
$relations = RelationFinder::forModel(new TestModel());
$relations = RelationFinder::forModel(new TestModel);

expect($relations)->toHaveCount(0);
});

it('can get the model info of the related model', function () {
/** @var Collection<Relation> $relations */
$relations = RelationFinder::forModel(new RelationTestModel());
$relations = RelationFinder::forModel(new RelationTestModel);

/** @var ModelInfo $modelInfo */
$modelInfo = $relations->first()->relatedModelInfo();
Expand Down

0 comments on commit 39125d5

Please sign in to comment.