From 0110a3b7b923230d744d557b8bff4801aee03aeb Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 2 Jan 2025 23:52:24 +0100 Subject: [PATCH] reformat code --- src/Entities/Subscriber.php | 18 +++++++++--------- src/Entities/Tag.php | 4 ++-- tests/unit/Entities/SubscriberTest.php | 7 ++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Entities/Subscriber.php b/src/Entities/Subscriber.php index ac17145..fcf7394 100644 --- a/src/Entities/Subscriber.php +++ b/src/Entities/Subscriber.php @@ -313,7 +313,7 @@ class Subscriber extends ArrayCollection } /** - * @return ?bool + * @return null|bool * @throws BaseException */ public function persist(): ?bool @@ -339,18 +339,18 @@ class Subscriber extends ArrayCollection return; } - $currentTags = $this->endpoint->get( $this->getId() )->getTags(); + $currentTags = $this->endpoint->get($this->getId())->getTags(); - $removeTags = array_diff( $currentTags->toArray(), $this->getTags()->toArray() ); - if ( count( $removeTags ) ) { - foreach ( $removeTags as $removeTag ) { - $this->endpoint->untag( $this->getEmailAddress(), $removeTag ); + $removeTags = array_diff($currentTags->toArray(), $this->getTags()->toArray()); + if (count($removeTags)) { + foreach ($removeTags as $removeTag) { + $this->endpoint->untag($this->getEmailAddress(), $removeTag); } } - $addTags = array_diff( $this->getTags()->toArray(), $currentTags->toArray() ); - if ( count( $addTags ) ) { - $this->endpoint->tag( $this->getEmailAddress(), array_diff( $this->getTags()->toArray(), $currentTags->toArray() ) ); + $addTags = array_diff($this->getTags()->toArray(), $currentTags->toArray()); + if (count($addTags)) { + $this->endpoint->tag($this->getEmailAddress(), $addTags); } } diff --git a/src/Entities/Tag.php b/src/Entities/Tag.php index 2503cf1..6861827 100644 --- a/src/Entities/Tag.php +++ b/src/Entities/Tag.php @@ -59,10 +59,10 @@ class Tag extends ArrayCollection } /** - * @return bool + * @return null|bool * @throws BaseException */ - public function persist(): bool + public function persist(): ?bool { return $this->endpoint?->update( $this->getId(), diff --git a/tests/unit/Entities/SubscriberTest.php b/tests/unit/Entities/SubscriberTest.php index a9578b6..00a5a82 100644 --- a/tests/unit/Entities/SubscriberTest.php +++ b/tests/unit/Entities/SubscriberTest.php @@ -626,8 +626,7 @@ class SubscriberTest extends TestCase ?array $newTagList, InvokedCount $removeTagInvocation, InvokedCount $setTagInvocation - ) - { + ) { $entityMock = $this->getMockBuilder(Subscriber::class) ->disableOriginalConstructor() ->onlyMethods(['getTags']) @@ -646,7 +645,9 @@ class SubscriberTest extends TestCase $endpointMock->expects($removeTagInvocation)->method('untag')->willReturn(true); $sut = new Subscriber(['id' => 'foo', 'email' => 'mymail@mydomain.tld'], $endpointSet ? $endpointMock : null); - if ($newTagList) $sut->set('tags', $newTagList); + if ($newTagList) { + $sut->set('tags', $newTagList); + } $this->callMethod( $sut,