Skip to content

Commit 0bf3a4a

Browse files
committed
making callable default to null
1 parent 7480643 commit 0bf3a4a

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/UseCases/PushDeletedToCyclopsUseCase.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ public function __construct(CyclopsService $cyclopsService)
1919
$this->cyclopsService = $cyclopsService;
2020
}
2121

22-
public function execute(CyclopsCustomerListEntity $list, callable $onCustomerDeleted)
22+
public function execute(CyclopsCustomerListEntity $list, callable $onCustomerDeleted = null)
2323
{
2424
foreach ($list->items as $item) {
2525
try {
2626
$this->cyclopsService->deleteCustomer($item->identity);
27-
$onCustomerDeleted($item);
28-
} catch (CustomerNotFoundException $exception) {
29-
$onCustomerDeleted($item);
27+
if ($onCustomerDeleted !== null) {
28+
$onCustomerDeleted($item);
29+
}
30+
} catch (CustomerNotFoundException $exception) {
31+
if ($onCustomerDeleted !== null) {
32+
$onCustomerDeleted($item);
33+
}
3034
} catch (CyclopsException $exception) {
3135
}
3236
}

src/UseCases/PushStaleToCyclopsUseCase.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ public function __construct(CyclopsService $cyclopsService)
1818
$this->cyclopsService = $cyclopsService;
1919
}
2020

21-
public function execute(CyclopsCustomerListEntity $list, callable $onCustomerCreated)
21+
public function execute(CyclopsCustomerListEntity $list, callable $onCustomerCreated = null)
2222
{
2323
foreach ($list->items as $item) {
2424
try {
2525
$this->cyclopsService->setBrandOptInStatus($item);
2626

27-
$onCustomerCreated($item);
27+
if ($onCustomerCreated !== null) {
28+
$onCustomerCreated($item);
29+
}
2830
} catch (CustomerNotFoundException $exception) {
2931
$customer = $this->cyclopsService->loadCustomer($item->identity);
3032
$customer->brandOptIn = $item->brandOptIn;
3133
$this->cyclopsService->setBrandOptInStatus($customer);
3234

33-
$onCustomerCreated($customer);
35+
if ($onCustomerCreated !== null) {
36+
$onCustomerCreated($customer);
37+
}
3438
}
3539
}
3640
}

tests/unit/UseCases/PushDeletedToCyclopsUseCaseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testDeletedPushedToCyclops()
4343
$list->items = [$createEntity('test@test.com'), $createEntity('test@testtest.com')];
4444

4545
$useCase = new PushDeletedToCyclopsUseCase($service);
46-
$useCase->execute($list, function() {});
46+
$useCase->execute($list);
4747
verify($deletedCount)->equals(2);
4848
}
4949
}

tests/unit/UseCases/PushStaleToCyclopsUseCaseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testStalePushedToCyclops()
4040
$list->items = [$createEntity('test@test.com'), $createEntity('test@testtest.com')];
4141

4242
$useCase = new PushStaleToCyclopsUseCase($service);
43-
$useCase->execute($list, function () {});
43+
$useCase->execute($list);
4444
verify($staleCount)->equals(2);
4545
}
4646
}

0 commit comments

Comments
 (0)