2323use ServiceBus \Scheduler \ScheduledOperationId ;
2424use ServiceBus \Scheduler \Store \Exceptions \ScheduledOperationNotFound ;
2525use ServiceBus \Scheduler \Store \SchedulerStore ;
26+
2627use function Amp \call ;
2728use function ServiceBus \Common \now ;
2829
@@ -41,37 +42,32 @@ public function __construct(SchedulerStore $store)
4142 public function emit (ScheduledOperationId $ id , ServiceBusContext $ context ): Promise
4243 {
4344 return call (
44- function () use ($ id , $ context ): \Generator
45- {
46- try
47- {
45+ function () use ($ id , $ context ): \Generator {
46+ try {
4847 yield $ this ->store ->extract ($ id , $ this ->createPostExtract ($ context ));
49- }
50- catch (ScheduledOperationNotFound $ exception )
51- {
48+ } catch (ScheduledOperationNotFound $ exception ) {
5249 $ context ->logger ()->throwable ($ exception );
5350
5451 yield $ context ->delivery (
5552 new SchedulerOperationEmitted ($ id )
5653 );
57- }
58- catch (\Throwable $ throwable )
59- {
54+ } catch (\Throwable $ throwable ) {
6055 throw new EmitFailed ($ throwable ->getMessage (), (int ) $ throwable ->getCode (), $ throwable );
6156 }
6257 }
6358 );
6459 }
6560
61+ /**
62+ * @psalm-suppress InvalidReturnType
63+ * @psalm-suppress InvalidReturnStatement
64+ */
6665 public function emitNextOperation (?NextScheduledOperation $ nextOperation , ServiceBusContext $ context ): Promise
6766 {
6867 return call (
69- function () use ($ nextOperation , $ context ): \Generator
70- {
71- try
72- {
73- if ($ nextOperation === null )
74- {
68+ function () use ($ nextOperation , $ context ): \Generator {
69+ try {
70+ if ($ nextOperation === null ) {
7571 $ context ->logger ()->debug ('Next operation not specified ' );
7672
7773 return ;
@@ -92,9 +88,7 @@ function () use ($nextOperation, $context): \Generator
9288 'scheduledOperationDelay ' => $ delay / 1000 ,
9389 ]
9490 );
95- }
96- catch (\Throwable $ throwable )
97- {
91+ } catch (\Throwable $ throwable ) {
9892 throw new EmitFailed ($ throwable ->getMessage (), (int ) $ throwable ->getCode (), $ throwable );
9993 }
10094 }
@@ -106,10 +100,8 @@ function () use ($nextOperation, $context): \Generator
106100 */
107101 private function createPostExtract (ServiceBusContext $ context ): callable
108102 {
109- return static function (?ScheduledOperation $ operation , ?NextScheduledOperation $ nextOperation ) use ($ context ): \Generator
110- {
111- if ($ operation !== null )
112- {
103+ return static function (?ScheduledOperation $ operation , ?NextScheduledOperation $ nextOperation ) use ($ context ): \Generator {
104+ if ($ operation !== null ) {
113105 yield $ context ->delivery ($ operation ->command );
114106 yield $ context ->delivery (new SchedulerOperationEmitted ($ operation ->id , $ nextOperation ));
115107
0 commit comments