From a7a8a5f5e3cb4601bd3c984e47d8dc8e7bc57862 Mon Sep 17 00:00:00 2001 From: Leandro Guindani Gehlen Date: Wed, 21 Dec 2022 10:07:19 -0300 Subject: [PATCH] Renamed method from `isSyncEnabled` to `shouldSync` --- src/Contracts/Syncable.php | 2 +- src/Database/Concerns/ResourceSyncing.php | 4 ++-- src/Database/Models/TenantPivot.php | 2 +- tests/ResourceSyncingTest.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Contracts/Syncable.php b/src/Contracts/Syncable.php index 5c35f317..0fe05695 100644 --- a/src/Contracts/Syncable.php +++ b/src/Contracts/Syncable.php @@ -16,5 +16,5 @@ interface Syncable public function triggerSyncEvent(); - public function isSyncEnabled(); + public function shouldSync(): bool; } diff --git a/src/Database/Concerns/ResourceSyncing.php b/src/Database/Concerns/ResourceSyncing.php index 3d6c4cc2..6db79dd2 100644 --- a/src/Database/Concerns/ResourceSyncing.php +++ b/src/Database/Concerns/ResourceSyncing.php @@ -14,7 +14,7 @@ trait ResourceSyncing { static::saved(function (Syncable $model) { /** @var ResourceSyncing $model */ - if ($model->isSyncEnabled()) { + if ($model->shouldSync()) { $model->triggerSyncEvent(); } }); @@ -34,7 +34,7 @@ trait ResourceSyncing event(new SyncedResourceSaved($this, tenant())); } - public function isSyncEnabled() + public function shouldSync(): bool { return true; } diff --git a/src/Database/Models/TenantPivot.php b/src/Database/Models/TenantPivot.php index 877d9466..3fb0118f 100644 --- a/src/Database/Models/TenantPivot.php +++ b/src/Database/Models/TenantPivot.php @@ -16,7 +16,7 @@ class TenantPivot extends Pivot static::saved(function (self $pivot) { $parent = $pivot->pivotParent; - if ($parent instanceof Syncable && $parent->isSyncEnabled()) { + if ($parent instanceof Syncable && $parent->shouldSync()) { $parent->triggerSyncEvent(); } }); diff --git a/tests/ResourceSyncingTest.php b/tests/ResourceSyncingTest.php index ea71ead4..bd71dad1 100644 --- a/tests/ResourceSyncingTest.php +++ b/tests/ResourceSyncingTest.php @@ -682,7 +682,7 @@ class CentralUser extends Model implements SyncMaster ]; } - public function isSyncEnabled() + public function shouldSync() { return $this->role !== 'not_sync'; } @@ -720,7 +720,7 @@ class ResourceUser extends Model implements Syncable ]; } - public function isSyncEnabled() + public function shouldSync() { return $this->role !== 'not_sync'; }