From abfe7fbbdcbf7c1e4d8f062f455987fcd63acba5 Mon Sep 17 00:00:00 2001 From: akiftezcan38 Date: Wed, 28 Feb 2024 13:32:55 +0000 Subject: [PATCH] Fix styling --- src/Traits/Connective.php | 16 ++++++++-------- tests/PackageTest.php | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Traits/Connective.php b/src/Traits/Connective.php index 801832b..af7426d 100644 --- a/src/Traits/Connective.php +++ b/src/Traits/Connective.php @@ -77,7 +77,7 @@ public function connections(string|array|null $connectionTypes = null, string|ar /** * @return ConnectiveCollection|null */ - public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, array|null $ignoreScopes = []): ?ConnectiveCollection + public function connectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = []): ?ConnectiveCollection { $connections = $this->connections($connectionTypes, $modelTypes); $collection = ConnectiveCollection::make(); @@ -86,13 +86,13 @@ public function connectives(string|array|null $connectionTypes = null, string|ar $toModelType = $connection->to_model_type; $toModelId = $connection->to_model_id; - if ($ignoreScopes && is_array($ignoreScopes)){ + if ($ignoreScopes && is_array($ignoreScopes)) { $toModelInstance = $toModelType::withoutGlobalScopes($ignoreScopes)->find($toModelId); - }else{ + } else { $toModelInstance = $toModelType::find($toModelId); } - if ($toModelInstance != null){ + if ($toModelInstance != null) { $collection->push($toModelInstance); } @@ -130,7 +130,7 @@ public function inverseConnections(string|array|null $connectionTypes = null, st /** * @return ConnectiveCollection|null */ - public function inverseConnectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, array|null $ignoreScopes = []): ?ConnectiveCollection + public function inverseConnectives(string|array|null $connectionTypes = null, string|array|null $modelTypes = null, ?array $ignoreScopes = []): ?ConnectiveCollection { $incomingConnections = $this->inverseConnections($connectionTypes, $modelTypes); $collection = ConnectiveCollection::make(); @@ -139,13 +139,13 @@ public function inverseConnectives(string|array|null $connectionTypes = null, st $fromModelType = $incomingConnection->from_model_type; $fromModelId = $incomingConnection->from_model_id; - if ($ignoreScopes && is_array($ignoreScopes)){ + if ($ignoreScopes && is_array($ignoreScopes)) { $fromModelInstance = $fromModelType::withoutGlobalScopes($ignoreScopes)->find($fromModelId); - }else{ + } else { $fromModelInstance = $fromModelType::find($fromModelId); } - if ($fromModelInstance != null){ + if ($fromModelInstance != null) { $collection->push($fromModelInstance); } diff --git a/tests/PackageTest.php b/tests/PackageTest.php index 10e2f0f..5d8a878 100644 --- a/tests/PackageTest.php +++ b/tests/PackageTest.php @@ -383,7 +383,6 @@ 'name' => 'name74', ]); - \AuroraWebSoftware\Connective\Tests\Models\Connective::addGlobalScope('name', function (\Illuminate\Database\Eloquent\Builder $builder) { $builder->where('name', 'name73'); }); @@ -392,10 +391,9 @@ $connective2->connectTo($connective4, 'a'); expect($connective2->connectives('a'))->toHaveCount(1); - expect($connective2->connectives('a', null,['name']))->toHaveCount(2); + expect($connective2->connectives('a', null, ['name']))->toHaveCount(2); }); - it('can get inverse connections of a connective model', function () { /**