Passed
Pull Request — main (#57)
by Thierry
15:28 queued 13s
created
src/Service/Meeting/PresenceService.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@
 block discarded – undo
66 66
     public function togglePresence(Session $session, Member $member)
67 67
     {
68 68
         !$session->absents()->find($member->id) ?
69
-            $session->absents()->attach($member->id) :
70
-            $session->absents()->detach($member->id);
69
+            $session->absents()->attach($member->id) : $session->absents()->detach($member->id);
71 70
     }
72 71
 
73 72
     /**
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Presence.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function selectSession(int $sessionId)
53 53
     {
54
-        if(!($session = $this->presenceService->getSession($sessionId)))
54
+        if (!($session = $this->presenceService->getSession($sessionId)))
55 55
         {
56 56
             // Todo: show en error message
57 57
             return $this->response;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function selectMember(int $memberId)
67 67
     {
68
-        if(!($member = $this->presenceService->getMember($memberId)))
68
+        if (!($member = $this->presenceService->getMember($memberId)))
69 69
         {
70 70
             // Todo: show en error message
71 71
             return $this->response;
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Session.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 
56 56
     public function resync(int $sessionId)
57 57
     {
58
-        if(!($session = $this->sessionService->getSession($sessionId)) || !$session->opened)
58
+        if (!($session = $this->sessionService->getSession($sessionId)) || !$session->opened)
59 59
         {
60 60
             $this->notify->error(trans('tontine.session.errors.not_opened'), trans('common.titles.error'));
61 61
             return $this->page();
Please login to merge, or discard this patch.
app/Ajax/Web/Planning/Round.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             'title' => trans('common.actions.cancel'),
69 69
             'class' => 'btn btn-tertiary',
70 70
             'click' => 'close',
71
-        ],[
71
+        ], [
72 72
             'title' => trans('common.actions.save'),
73 73
             'class' => 'btn btn-primary',
74 74
             'click' => $this->rq()->create(pm()->form('round-form')),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             'title' => trans('common.actions.cancel'),
100 100
             'class' => 'btn btn-tertiary',
101 101
             'click' => 'close',
102
-        ],[
102
+        ], [
103 103
             'title' => trans('common.actions.save'),
104 104
             'class' => 'btn btn-primary',
105 105
             'click' => $this->rq()->update($round->id, pm()->form('round-form')),
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $this->notify->success(trans('tontine.round.messages.deleted'), trans('common.titles.success'));
129 129
 
130 130
         $currentRound = $this->tenantService->round();
131
-        if($currentRound !== null && $currentRound->id === $roundId)
131
+        if ($currentRound !== null && $currentRound->id === $roundId)
132 132
         {
133 133
             // If the currently selected round is deleted, then choose another.
134 134
             $this->cl(Select::class)->saveTontine($this->tenantService->tontine()->id);
Please login to merge, or discard this patch.
app/Ajax/Web/Planning/PoolRound.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     protected function getPool()
46 46
     {
47
-        $poolId = $this->target()->method() === 'home' ? $this->target()->args()[0] :
48
-            (int)$this->bag('pool.round')->get('pool.id');
47
+        $poolId = $this->target()->method() === 'home' ? $this->target()->args()[0] : (int) $this->bag('pool.round')->get('pool.id');
49 48
         $this->pool = $this->poolService->getPool($poolId);
50 49
     }
51 50
 
@@ -57,7 +56,7 @@  discard block
 block discarded – undo
57 56
         $this->response->html('pool-round-actions', $html);
58 57
         $this->jq('#btn-pool-round-back')->click($this->rq(Pool::class)->home());
59 58
         $this->jq('#btn-pool-round-save')->click($this->rq()->saveRound(pm()->form('round-form')));
60
-        if($this->pool->pool_round)
59
+        if ($this->pool->pool_round)
61 60
         {
62 61
             $this->jq('#btn-pool-round-delete')->click($this->rq()->deleteRound()
63 62
                 ->confirm(trans('tontine.pool_round.questions.delete')));
@@ -65,7 +64,7 @@  discard block
 block discarded – undo
65 64
 
66 65
         $defaultLabel = trans('tontine.pool_round.labels.default');
67 66
         $startSession = !$this->pool->pool_round ? $defaultLabel : $this->pool->start_date;
68
-        $endSession =  !$this->pool->pool_round ? $defaultLabel : $this->pool->end_date;
67
+        $endSession = !$this->pool->pool_round ? $defaultLabel : $this->pool->end_date;
69 68
         $this->response->html('pool-round-start-session-title',
70 69
             trans('tontine.pool_round.titles.start_session', ['session' => $startSession]));
71 70
         $this->response->html('pool-round-end-session-title',
@@ -75,12 +74,12 @@  discard block
 block discarded – undo
75 74
     private function getSessionPageNumber(SessionModel $session): int
76 75
     {
77 76
         $sessionCount = $this->sessionService->getTontineSessionCount($session, true, false);
78
-        return (int)($sessionCount / $this->tenantService->getLimit()) + 1;
77
+        return (int) ($sessionCount / $this->tenantService->getLimit()) + 1;
79 78
     }
80 79
 
81 80
     public function home(int $poolId)
82 81
     {
83
-        if(!$this->pool)
82
+        if (!$this->pool)
84 83
         {
85 84
             return $this->response;
86 85
         }
@@ -97,7 +96,7 @@  discard block
 block discarded – undo
97 96
 
98 97
         $startPageNumber = 1;
99 98
         $endPageNumber = 1;
100
-        if($this->pool->pool_round !== null)
99
+        if ($this->pool->pool_round !== null)
101 100
         {
102 101
             // Go to the pages of the round start and end sessions.
103 102
             $startPageNumber = $this->getSessionPageNumber($this->pool->pool_round->start_session);
@@ -172,7 +171,7 @@  discard block
 block discarded – undo
172 171
 
173 172
     public function showStartSessionPage()
174 173
     {
175
-        if(!$this->pool->pool_round)
174
+        if (!$this->pool->pool_round)
176 175
         {
177 176
             return $this->response;
178 177
         }
@@ -185,7 +184,7 @@  discard block
 block discarded – undo
185 184
 
186 185
     public function showEndSessionPage()
187 186
     {
188
-        if(!$this->pool->pool_round)
187
+        if (!$this->pool->pool_round)
189 188
         {
190 189
             return $this->response;
191 190
         }
Please login to merge, or discard this patch.
src/Service/Meeting/SessionService.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function checkPoolsSubscriptions()
33 33
     {
34
-        if($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0)
34
+        if ($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0)
35 35
         {
36 36
             throw new MessageException(trans('tontine.errors.action') .
37 37
                 '<br/>' . trans('tontine.pool.errors.no_subscription'));
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function openSession(Session $session)
96 96
     {
97
-        if($session->pending)
97
+        if ($session->pending)
98 98
         {
99 99
             // If the session is getting opened for the first time, then
100 100
             // its also needs to get synced with charges and subscriptions.
101 101
             $this->syncSession($session);
102 102
             return;
103 103
         }
104
-        if(!$session->opened)
104
+        if (!$session->opened)
105 105
         {
106 106
             // Open the session
107 107
             $session->update(['status' => Session::STATUS_OPENED]);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function resyncSession(Session $session)
131 131
     {
132
-        if($session->opened)
132
+        if ($session->opened)
133 133
         {
134 134
             $this->syncSession($session);
135 135
         }
Please login to merge, or discard this patch.
src/Service/Traits/EventTrait.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function chargeCreated(Tontine $tontine, Charge $charge)
100 100
     {
101
-        if(!$charge->period_once)
101
+        if (!$charge->period_once)
102 102
         {
103 103
             return;
104 104
         }
105 105
         $today = now();
106 106
         // Create a tontine bill for each member
107
-        foreach($tontine->members()->get() as $member)
107
+        foreach ($tontine->members()->get() as $member)
108 108
         {
109 109
             $this->createTontineBill($charge, $member, $today);
110 110
         }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $today = now();
122 122
         // Create a tontine bill for each charge
123
-        foreach($tontine->charges()->active()->once()->get() as $charge)
123
+        foreach ($tontine->charges()->active()->once()->get() as $charge)
124 124
         {
125 125
             $this->createTontineBill($charge, $member, $today);
126 126
         }
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
         ])->get();
144 144
         $roundCharges = $tontine->charges()->active()->round()->get();
145 145
         // Create a round bill for each member
146
-        foreach($members as $member)
146
+        foreach ($members as $member)
147 147
         {
148
-            foreach($roundCharges as $charge)
148
+            foreach ($roundCharges as $charge)
149 149
             {
150 150
                 $count = $member->round_bills->filter(function($bill) use($charge) {
151 151
                     return $bill->charge_id = $charge->id;
152 152
                 })->count();
153
-                if($count === 0)
153
+                if ($count === 0)
154 154
                 {
155 155
                     $this->createRoundBill($charge, $member, $round, $today);
156 156
                 }
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
         }
159 159
         $tontineCharges = $tontine->charges()->active()->once()->get();
160 160
         // Create a tontine bill for each member
161
-        foreach($members as $member)
161
+        foreach ($members as $member)
162 162
         {
163
-            foreach($tontineCharges as $charge)
163
+            foreach ($tontineCharges as $charge)
164 164
             {
165 165
                 $count = $member->tontine_bills->filter(function($bill) use($charge) {
166 166
                     return $bill->charge_id = $charge->id;
167 167
                 })->count();
168
-                if($count === 0)
168
+                if ($count === 0)
169 169
                 {
170 170
                     $this->createTontineBill($charge, $member, $today);
171 171
                 }
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
         $sessionCharges = $tontine->charges()->active()->session()->get();
194 194
 
195 195
         // Sync the session bills for each member and each session charge
196
-        foreach($sessionCharges as $charge)
196
+        foreach ($sessionCharges as $charge)
197 197
         {
198
-            foreach($members as $member)
198
+            foreach ($members as $member)
199 199
             {
200 200
                 $count = $member->session_bills->filter(function($bill) use($charge) {
201 201
                     return $bill->charge_id = $charge->id;
202 202
                 })->count();
203
-                if($count === 0)
203
+                if ($count === 0)
204 204
                 {
205 205
                     $this->createSessionBill($charge, $member, $session, $today);
206 206
                 }
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
         // Sync the receivables for each subscription on each pool
211 211
         /** @var array<Pool> */
212 212
         $pools = Pool::ofSession($session)->get();
213
-        foreach($pools as $pool)
213
+        foreach ($pools as $pool)
214 214
         {
215
-            if($session->enabled($pool))
215
+            if ($session->enabled($pool))
216 216
             {
217 217
                 $subscriptions = $pool->subscriptions()
218 218
                     ->whereDoesntHave('receivables', function(Builder $query) use($session) {
219 219
                         return $query->where('session_id', $session->id);
220 220
                     });
221
-                foreach($subscriptions->get() as $subscription)
221
+                foreach ($subscriptions->get() as $subscription)
222 222
                 {
223 223
                     $subscription->receivables()->create(['session_id' => $session->id]);
224 224
                 }
Please login to merge, or discard this patch.
src/Service/Meeting/Charge/BillService.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @return Builder
40 40
      */
41 41
     private function getBillsQuery(Charge $charge, Session $session,
42
-        string $search = '', ?bool $onlyPaid = null): Builder|Relation
42
+        string $search = '', ?bool $onlyPaid = null): Builder | Relation
43 43
     {
44 44
         $search = trim($search);
45 45
         return Bill::ofSession($session)->with('session')
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @return Builder|Relation
126 126
      */
127 127
     private function getMembersQuery(Charge $charge, Session $session,
128
-        string $search = '', ?bool $filter): Builder|Relation
128
+        string $search = '', ?bool $filter): Builder | Relation
129 129
     {
130 130
         $filterFunction = function($query) use($charge, $session) {
131 131
             $query->where('charge_id', $charge->id)->where('session_id', $session->id);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                     $member->libre_bills->first()->bill : null;
171 171
             });
172 172
         // Check if there is a settlement target.
173
-        if(!($target = $this->targetService->getTarget($charge, $session)))
173
+        if (!($target = $this->targetService->getTarget($charge, $session)))
174 174
         {
175 175
             return $members;
176 176
         }
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
         int $memberId, bool $paid, float $amount = 0): void
212 212
     {
213 213
         $member = $this->tenantService->tontine()->members()->find($memberId);
214
-        if(!$member)
214
+        if (!$member)
215 215
         {
216 216
             throw new MessageException(trans('tontine.member.errors.not_found'));
217 217
         }
218 218
 
219
-        if($amount !== 0)
219
+        if ($amount !== 0)
220 220
         {
221 221
             $amount = $this->localeService->convertMoneyToInt($amount);
222 222
         }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
             $libreBill->session()->associate($session);
234 234
             $libreBill->bill()->associate($bill);
235 235
             $libreBill->save();
236
-            if($paid)
236
+            if ($paid)
237 237
             {
238 238
                 $settlement = new Settlement();
239 239
                 $settlement->bill()->associate($bill);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      */
253 253
     public function getMemberBill(Charge $charge, Session $session, int $memberId): ?LibreBill
254 254
     {
255
-        if(!($member = $this->tenantService->tontine()->members()->find($memberId)))
255
+        if (!($member = $this->tenantService->tontine()->members()->find($memberId)))
256 256
         {
257 257
             throw new MessageException(trans('tontine.member.errors.not_found'));
258 258
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public function updateBill(Charge $charge, Session $session, int $memberId, float $amount): void
276 276
     {
277
-        if(!($libreBill = $this->getMemberBill($charge, $session, $memberId)))
277
+        if (!($libreBill = $this->getMemberBill($charge, $session, $memberId)))
278 278
         {
279 279
             return; // throw new MessageException(trans('tontine.bill.errors.not_found'));
280 280
         }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function deleteBill(Charge $charge, Session $session, int $memberId): void
295 295
     {
296
-        if(!($libreBill = $this->getMemberBill($charge, $session, $memberId)))
296
+        if (!($libreBill = $this->getMemberBill($charge, $session, $memberId)))
297 297
         {
298 298
             return; // throw new MessageException(trans('tontine.bill.errors.not_found'));
299 299
         }
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
         DB::transaction(function() use($libreBill, $session) {
302 302
             $bill = $libreBill->bill;
303 303
             $libreBill->delete();
304
-            if($bill !== null)
304
+            if ($bill !== null)
305 305
             {
306 306
                 // Delete the settlement only if it is on the same session
307
-                if($bill->settlement !== null && $bill->settlement->session_id === $session->id)
307
+                if ($bill->settlement !== null && $bill->settlement->session_id === $session->id)
308 308
                 {
309 309
                     $bill->settlement->delete();
310 310
                 }
Please login to merge, or discard this patch.
src/Service/Tontine/GuestService.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
         $guest = User::where('email', $guestEmail)
110 110
             ->with('guest_invites', fn($query) => $query->where('host_id', $host->id))
111 111
             ->first();
112
-        if(!$guest)
112
+        if (!$guest)
113 113
         {
114 114
             throw new MessageException(trans('tontine.invite.errors.user_not_found'));
115 115
         }
116
-        if($guest->id === $host->id || $guest->guest_invites->count() > 0)
116
+        if ($guest->id === $host->id || $guest->guest_invites->count() > 0)
117 117
         {
118 118
             throw new MessageException(trans('tontine.invite.errors.cannot_invite'));
119 119
         }
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function acceptInvite(int $inviteId)
139 139
     {
140
-        if(!($invite = $this->getGuestInvite($inviteId)))
140
+        if (!($invite = $this->getGuestInvite($inviteId)))
141 141
         {
142 142
             throw new MessageException(trans('tontine.invite.errors.invite_not_found'));
143 143
         }
144
-        if($invite->is_expired)
144
+        if ($invite->is_expired)
145 145
         {
146 146
             throw new MessageException(trans('tontine.invite.errors.invite_expired'));
147 147
         }
148
-        if(!$invite->is_pending)
148
+        if (!$invite->is_pending)
149 149
         {
150 150
             throw new MessageException(trans('tontine.invite.errors.not_allowed'));
151 151
         }
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function refuseInvite(int $inviteId)
163 163
     {
164
-        if(!($invite = $this->getGuestInvite($inviteId)))
164
+        if (!($invite = $this->getGuestInvite($inviteId)))
165 165
         {
166 166
             throw new MessageException(trans('tontine.invite.errors.invite_not_found'));
167 167
         }
168
-        if($invite->is_expired)
168
+        if ($invite->is_expired)
169 169
         {
170 170
             throw new MessageException(trans('tontine.invite.errors.invite_expired'));
171 171
         }
172
-        if(!$invite->is_pending)
172
+        if (!$invite->is_pending)
173 173
         {
174 174
             throw new MessageException(trans('tontine.invite.errors.not_allowed'));
175 175
         }
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function cancelInvite(int $inviteId)
187 187
     {
188
-        if(!($invite = $this->getHostInvite($inviteId)))
188
+        if (!($invite = $this->getHostInvite($inviteId)))
189 189
         {
190 190
             throw new MessageException(trans('tontine.invite.errors.invite_not_found'));
191 191
         }
192
-        if($invite->is_expired)
192
+        if ($invite->is_expired)
193 193
         {
194 194
             throw new MessageException(trans('tontine.invite.errors.invite_expired'));
195 195
         }
196
-        if(!$invite->is_pending)
196
+        if (!$invite->is_pending)
197 197
         {
198 198
             throw new MessageException(trans('tontine.invite.errors.not_allowed'));
199 199
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public function deleteHostInvite(int $inviteId)
226 226
     {
227
-        if(!($invite = $this->getHostInvite($inviteId)))
227
+        if (!($invite = $this->getHostInvite($inviteId)))
228 228
         {
229 229
             throw new MessageException(trans('tontine.invite.errors.invite_not_found'));
230 230
         }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function deleteGuestInvite(int $inviteId): bool
243 243
     {
244
-        if(!($invite = $this->getGuestInvite($inviteId)))
244
+        if (!($invite = $this->getGuestInvite($inviteId)))
245 245
         {
246 246
             throw new MessageException(trans('tontine.invite.errors.invite_not_found'));
247 247
         }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     {
284 284
         DB::transaction(function() use($invite, $tontine, $access) {
285 285
             $invite->tontines()->detach($tontine->id);
286
-            if(count($access) > 0)
286
+            if (count($access) > 0)
287 287
             {
288 288
                 $invite->tontines()->attach($tontine->id, ['access' => $access]);
289 289
             }
Please login to merge, or discard this patch.